Skip to content

Commit 36601e4

Browse files
committed
Update README.md
1 parent d2622a8 commit 36601e4

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,32 @@ for more examples.
9292
end program example1
9393
```
9494

95+
Modifying variables in a JSON file
96+
---------------
97+
98+
After reading a JSON file, if you want to change the values of some of the variables, you can use the ```update``` method. For the example above:
99+
100+
```fortran
101+
! [found can be used to check if the data was really there]
102+
call json%update('version.major',9,found) !change major version to 9
103+
call json%update('version.minor',0,found) !change minor version to 0
104+
call json%update('version.patch',0,found) !change patch to 0
105+
```
106+
95107
Writing a JSON file
96108
---------------
97109

98-
Writing a json file is slightly more complicated and involves the use
110+
To print the JSON file (either to a file or the console), the ```print_file``` method can be used. For the above example:
111+
112+
```fortran
113+
call json%print_file() !prints to the console
114+
call json%print_file(iunit) !prints to the file connnected to iunit
115+
```
116+
117+
Building a JSON file from scratch
118+
---------------
119+
120+
Constructing a JSON file element by element is slightly more complicated and involves the use
99121
of pointers. See the json_example.f90 file for more examples.
100122

101123
```fortran

0 commit comments

Comments
 (0)