Closed nyckmaia closed 5 years ago
I think update
only works if the variable is already there. Have you tried add
?
Thanks @jacobwilliams ...
Yes...today I change my Fortran source-code to use the add
method intead of update
method.
Now, add
works as really "adding" a new field AND... if the field already exists, the add
method works like a update
method....replacing the old value by the new one.
So, I'm thinking that I can use only the add
method...for "adding" and "update" JSON fields/values.
I don't understand why yesterday the update
method was working like "adding" new fields too. But, today, the update
method only "updates" a existent JSON field and the add
method "adds" and "updates" JSON fields.
Thank you for your help!
I have a C++ application that call a Fortran subroutine (using ISO_C_BINDING) passing a
const C char*
that contains the JSON file full path as input argument. It works well, like this pseudo-code below:In this example you can see that I use the
update
method to create a newdate_time
JSON field in my file. This fielddate_time
really not exist in the current file. It is created at run-time. Ok!So, this loaded JSON object has a JSON field called
settings_path
, that stores another JSON file path.I can get the
settings_path
value using theget
method, but when I create another JSON object using thesettings_path
string and tried to add new fields inside of it, my Fortran code crash!Here is my example:
Trying a lot of things, I discovery that, if I open this "settings" JSON file and I create the field
version
manually, the Fortran update/change the value without errors. But I would like to Fortran creates the new JSON fieldversion
at run-time, like my first example above.Why the first goes Ok, and the second crashs?