@@ -13,7 +13,8 @@ module jf_test_1_mod
13
13
implicit none
14
14
15
15
character (len=* ),parameter :: dir = ' ../files/inputs/' ! ! working directory
16
- character (len=* ),parameter :: filename1 = ' test1.json'
16
+ character (len=* ),parameter :: filename1 = ' test1.json' ! ! file to read
17
+ logical :: namelist_style ! ! for printing JSON variable paths
17
18
18
19
contains
19
20
@@ -68,12 +69,25 @@ subroutine test_1(error_cnt)
68
69
error_cnt = error_cnt + 1
69
70
end if
70
71
72
+ ! -------------------------
71
73
! print each variable:
72
- write (error_unit,' (A)' ) ' '
73
- write (error_unit,' (A)' ) ' printing each variable...'
74
+
74
75
call core% initialize()
75
76
call json% get(p) ! get root
76
- call core% traverse(p,print_json_variable) ! print all the variables
77
+
78
+ namelist_style = .true.
79
+ write (error_unit,' (A)' ) ' '
80
+ write (error_unit,' (A)' ) ' printing each variable [namelist style]'
81
+ write (error_unit,' (A)' ) ' '
82
+ call core% traverse(p,print_json_variable)
83
+
84
+ namelist_style = .false.
85
+ write (error_unit,' (A)' ) ' '
86
+ write (error_unit,' (A)' ) ' printing each variable [JSON style]'
87
+ write (error_unit,' (A)' ) ' '
88
+ call core% traverse(p,print_json_variable)
89
+
90
+ ! -------------------------
77
91
78
92
! extract data from the parsed value
79
93
write (error_unit,' (A)' ) ' '
@@ -305,9 +319,13 @@ subroutine print_json_variable(json,p,finished)
305
319
306
320
! only print the leafs:
307
321
if (.not. associated (child)) then
308
- call json% get_path(p,path,found,&
309
- use_alt_array_tokens= .true. ,&
310
- path_sep= json_CK_' %' ) ! fortran-style
322
+ if (namelist_style) then
323
+ call json% get_path(p,path,found,&
324
+ use_alt_array_tokens= .true. ,&
325
+ path_sep= json_CK_' %' ) ! fortran-style
326
+ else
327
+ call json% get_path(p,path,found) ! JSON-style
328
+ end if
311
329
if (found) then
312
330
313
331
call json% info(p,var_type= var_type)
0 commit comments