jacobwilliams / json-fortran

A Modern Fortran JSON API
https://jacobwilliams.github.io/json-fortran/
Other
333 stars 83 forks source link

Double back slash problem #436

Closed nyckmaia closed 5 years ago

nyckmaia commented 5 years ago

I have 2 JSON files: "main.json" and "another.json" Inside the "main.json" file I have a path field that is equal to the "another.json" file path. Like:

! Two JSON files:
type(json_file) :: main
type(json_file) :: another

! Load Main file:
call main%load_file(filename = "path_to_main_file.json")
! Get full path to Another file:
call main%get('another_path', another_path, found)

! Load Another file:
call another%load_file(filename = another_path) 

My another.json

{
    "another_path": "C:/Users/xxx/Desktop/my_file.json"
}

My problem is: The "another.json" file is using "single slash" (like unix systems), but I'm using Windows 10 x64.

When I tried to use methods like another%add or another%update, it doesn't work!

So, I modified manually my "another.json" file like this:

My another.json (modified)

{
    "another_path": "C:\\Users\\xxx\\Desktop\\my_file.json"
}

Using double AND back slashs it works well.

I would like to develop a cross-platform application. So, how can I use the JSON-Fortran library methods (like %add, %update, etc...) when the JSON object was loaded using a "single unix slash" filename string?

Thank you,

jacobwilliams commented 5 years ago

I'd need to see a full reproducer of the issue that I can compile and run. The slashes shouldn't matter for add or update so something else is probably the problem.

nyckmaia commented 5 years ago

Thank you @jacobwilliams for your patience and good help.

I really don't know what was happening yesterday with my Fortran source-code, but today now its working perfect on Windows x64 without need the "double back slashs"... Your JSON-Fortran library is running perfectly in my source-code now!

Sorry about that...and thank you for your quick response!