@@ -13,7 +13,8 @@ module jf_test_1_mod
1313 implicit none
1414
1515 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
1718
1819contains
1920
@@ -68,12 +69,25 @@ subroutine test_1(error_cnt)
6869 error_cnt = error_cnt + 1
6970 end if
7071
72+ ! -------------------------
7173 ! print each variable:
72- write (error_unit,' (A)' ) ' '
73- write (error_unit,' (A)' ) ' printing each variable...'
74+
7475 call core% initialize()
7576 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+ ! -------------------------
7791
7892 ! extract data from the parsed value
7993 write (error_unit,' (A)' ) ' '
@@ -305,9 +319,13 @@ subroutine print_json_variable(json,p,finished)
305319
306320 ! only print the leafs:
307321 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
311329 if (found) then
312330
313331 call json% info(p,var_type= var_type)
0 commit comments