@@ -92,6 +92,7 @@ module json_value_module
92
92
! >
93
93
! Type used to construct the linked-list JSON structure.
94
94
! Normally, this should always be a pointer variable.
95
+ ! This type should only be used by an instance of [[json_core]].
95
96
!
96
97
! # Example
97
98
!
@@ -178,27 +179,34 @@ module json_value_module
178
179
179
180
integer (IK) :: spaces_per_tab = 2 ! ! number of spaces for indenting
180
181
181
- logical (LK) :: compact_real = .true. ! ! to use the "compact" form of real numbers for output
182
- character (kind= CDK,len= :),allocatable :: real_fmt ! ! the format string to use for real numbers
183
- ! ! it is set in [[json_initialize]]
184
-
185
- logical (LK) :: is_verbose = .false. ! ! if true, all exceptions are immediately printed to console
186
- logical (LK) :: exception_thrown = .true. ! ! the error flag (by default, this is true to
187
- ! ! make sure that [[json_initialize]] is called.
182
+ logical (LK) :: compact_real = .true. ! ! to use the "compact" form of real
183
+ ! ! numbers for output
184
+ character (kind= CDK,len= :),allocatable :: real_fmt ! ! the format string to use
185
+ ! ! for real numbers. it is
186
+ ! ! set in [[json_initialize]]
187
+
188
+ logical (LK) :: is_verbose = .false. ! ! if true, all exceptions are
189
+ ! ! immediately printed to console
190
+ logical (LK) :: exception_thrown = .true. ! ! the error flag (by default,
191
+ ! ! this is true to make sure that
192
+ ! ! [[json_initialize]] is called so
193
+ ! ! that the `real_fmt` can be set.
188
194
character (kind= CK,len= :),allocatable :: err_message ! ! the error message
189
195
190
196
integer (IK) :: char_count = 0 ! ! character position in the current line
191
197
integer (IK) :: line_count = 1 ! ! lines read counter
192
198
integer (IK) :: pushed_index = 0 ! ! used when parsing lines in file
193
- character (kind= CK,len= pushed_char_size) :: pushed_char = ' ' ! ! used when parsing lines in file
199
+ character (kind= CK,len= pushed_char_size) :: pushed_char = ' ' ! ! used when parsing
200
+ ! ! lines in file
194
201
195
202
integer (IK) :: ipos = 1 ! ! for allocatable strings: next character to read
196
203
197
204
contains
198
205
199
206
private
200
207
201
- generic,public :: get_child = > json_value_get_by_index, MAYBEWRAP(json_value_get_by_name_chars)
208
+ generic,public :: get_child = > json_value_get_by_index, &
209
+ MAYBEWRAP(json_value_get_by_name_chars)
202
210
procedure ,private :: json_value_get_by_index
203
211
procedure ,private :: MAYBEWRAP(json_value_get_by_name_chars)
204
212
@@ -214,10 +222,10 @@ module json_value_module
214
222
MAYBEWRAP(json_value_add_string), &
215
223
MAYBEWRAP(json_value_add_string_vec)
216
224
#ifdef USE_UCS4
217
- generic,public :: add = > json_value_add_string_name_ascii, &
218
- json_value_add_string_val_ascii, &
219
- json_value_add_string_vec_name_ascii, &
220
- json_value_add_string_vec_val_ascii
225
+ generic,public :: add = > json_value_add_string_name_ascii, &
226
+ json_value_add_string_val_ascii, &
227
+ json_value_add_string_vec_name_ascii, &
228
+ json_value_add_string_vec_val_ascii
221
229
#endif
222
230
223
231
procedure ,private :: json_value_add_member
@@ -237,8 +245,8 @@ module json_value_module
237
245
#endif
238
246
239
247
! >
240
- ! These are like [[json_add]] , except if a child with the same name is
241
- ! already present, then its value is simply updated.
248
+ ! These are like the `add` methods , except if a child with the
249
+ ! same name is already present, then its value is simply updated.
242
250
! Note that currently, these only work for scalar variables.
243
251
! These routines can also change the variable's type (but an error will be
244
252
! thrown if the existing variable is not a scalar).
@@ -251,8 +259,8 @@ module json_value_module
251
259
MAYBEWRAP(json_update_integer),&
252
260
MAYBEWRAP(json_update_string)
253
261
#ifdef USE_UCS4
254
- generic,public :: update = > json_update_string_name_ascii,&
255
- json_update_string_val_ascii
262
+ generic,public :: update = > json_update_string_name_ascii,&
263
+ json_update_string_val_ascii
256
264
#endif
257
265
procedure ,private :: MAYBEWRAP(json_update_logical)
258
266
procedure ,private :: MAYBEWRAP(json_update_double)
@@ -306,8 +314,8 @@ module json_value_module
306
314
! !...
307
315
! call json%print(p,'test.json') !this is [[json_print_2]]
308
316
! ````
309
- generic,public :: print = > json_value_print, json_print_1,json_print_2
310
- procedure :: json_value_print, json_print_1,json_print_2
317
+ generic,public :: print = > json_print_1,json_print_2
318
+ procedure :: json_print_1,json_print_2
311
319
312
320
! >
313
321
! Destructor routine for a [[json_value]] pointer.
@@ -497,6 +505,7 @@ module json_value_module
497
505
procedure ,public :: print_error_message = > json_print_error_message ! ! simply routine to print error messages
498
506
499
507
! other private routines:
508
+ procedure :: json_value_print
500
509
procedure :: string_to_integer
501
510
procedure :: string_to_double
502
511
procedure :: unescape_string
@@ -907,7 +916,7 @@ end subroutine wrap_json_throw_exception
907
916
! date: 12/4/2013
908
917
!
909
918
! Retrieve error code from the [[json_core]].
910
- ! This should be called after [[json_parse]] to check for errors.
919
+ ! This should be called after `parse` to check for errors.
911
920
! If an error is thrown, before using the class again, [[json_initialize]]
912
921
! should be called to clean up before it is used again.
913
922
!
@@ -2322,7 +2331,7 @@ subroutine json_value_to_string(json,me,str)
2322
2331
character (kind= CK,len= :),intent (out ),allocatable :: str ! ! prints structure to this string
2323
2332
2324
2333
str = ' '
2325
- call json% print (me, iunit= unit2str, str= str, indent= 1 , colon= .true. )
2334
+ call json% json_value_print (me, iunit= unit2str, str= str, indent= 1 , colon= .true. )
2326
2335
2327
2336
end subroutine json_value_to_string
2328
2337
! *****************************************************************************************
@@ -2344,7 +2353,7 @@ subroutine json_print_1(json,me,iunit)
2344
2353
character (kind= CK,len= :),allocatable :: dummy
2345
2354
2346
2355
if (iunit/= unit2str) then
2347
- call json% print (me,iunit,str= dummy, indent= 1 , colon= .true. )
2356
+ call json% json_value_print (me,iunit,str= dummy, indent= 1 , colon= .true. )
2348
2357
else
2349
2358
call json% throw_exception(' Error in json_print_1: iunit must not be -1.' )
2350
2359
end if
@@ -2385,8 +2394,7 @@ end subroutine json_print_2
2385
2394
! Print the JSON structure to a string or a file.
2386
2395
!
2387
2396
! # Notes
2388
- ! * This is an internal routine called by the wrapper routines
2389
- ! [[json_print]] and [[json_value_to_string]].
2397
+ ! * This is an internal routine called by the various wrapper routines.
2390
2398
! * The reason the str argument is non-optional is because of a
2391
2399
! bug in v4.9 of the gfortran compiler.
2392
2400
@@ -2489,7 +2497,7 @@ recursive subroutine json_value_print(json,me,iunit,str,indent,need_comma,colon,
2489
2497
end if
2490
2498
2491
2499
! recursive print of the element
2492
- call json% print (element, iunit= iunit, indent= tab + 1 , &
2500
+ call json% json_value_print (element, iunit= iunit, indent= tab + 1 , &
2493
2501
need_comma= i< count, colon= .true. , str= str)
2494
2502
2495
2503
! get the next child the list:
@@ -2521,7 +2529,7 @@ recursive subroutine json_value_print(json,me,iunit,str,indent,need_comma,colon,
2521
2529
do i = 1 , count
2522
2530
2523
2531
! recursive print of the element
2524
- call json% print (element, iunit= iunit, indent= tab,&
2532
+ call json% json_value_print (element, iunit= iunit, indent= tab,&
2525
2533
need_comma= i< count, is_array_element= .true. , str= str)
2526
2534
2527
2535
! get the next child the list:
@@ -2662,7 +2670,7 @@ end subroutine json_value_print
2662
2670
!
2663
2671
! Thus, if any of these characters are present in the name key,
2664
2672
! this routine cannot be used to get the value.
2665
- ! In that case, the [[json_get_child]] routines would need to be used.
2673
+ ! In that case, the `get_child` methods would need to be used.
2666
2674
2667
2675
subroutine json_get_by_path (json , me , path , p , found )
2668
2676
@@ -3945,7 +3953,7 @@ end subroutine wrap_json_get_string_vec_with_path
3945
3953
! for each element in the array.
3946
3954
!
3947
3955
! @note For integer, double, logical, and character arrays,
3948
- ! higher-level routines are provided (see [[json_get]] ), so
3956
+ ! higher-level routines are provided (see `get` methods ), so
3949
3957
! this routine does not have to be used for those cases.
3950
3958
3951
3959
subroutine json_get_array (json , me , array_callback )
@@ -4109,8 +4117,9 @@ end subroutine wrap_json_get_array_with_path
4109
4117
! # Example
4110
4118
!
4111
4119
! ````fortran
4120
+ ! type(json_core) :: json
4112
4121
! type(json_value),pointer :: p
4113
- ! call json_parse (file='myfile.json', p=p)
4122
+ ! call json%parse (file='myfile.json', p=p)
4114
4123
! ````
4115
4124
!
4116
4125
! # History
@@ -4241,7 +4250,7 @@ end subroutine json_parse_string
4241
4250
4242
4251
! *****************************************************************************************
4243
4252
! >
4244
- ! Alternate version of [[json_parse_string]], where " str" is kind=CDK.
4253
+ ! Alternate version of [[json_parse_string]], where ` str` is kind=CDK.
4245
4254
4246
4255
subroutine wrap_json_parse_string (json , p , str )
4247
4256
@@ -4547,7 +4556,7 @@ end subroutine json_value_create_logical
4547
4556
! *****************************************************************************************
4548
4557
! > author: Izaak Beekman
4549
4558
!
4550
- ! Wrapper for [[json_value_create_logical]] so [[json_create_logical]] can
4559
+ ! Wrapper for [[json_value_create_logical]] so `create_logical` method can
4551
4560
! be called with name of character kind 'DEFAULT' or 'ISO_10646'
4552
4561
4553
4562
subroutine wrap_json_value_create_logical (json ,me ,val ,name )
@@ -4594,9 +4603,9 @@ end subroutine json_value_create_integer
4594
4603
! *****************************************************************************************
4595
4604
! > author: Izaak Beekman
4596
4605
!
4597
- ! A wrapper procedure for [[json_value_create_integer]] so that [[json_create_integer]]
4598
- ! may be called with either a 'DEFAULT' or 'ISO_10646' character kind 'name'
4599
- ! actual argument.
4606
+ ! A wrapper procedure for [[json_value_create_integer]] so that `create_integer`
4607
+ ! method may be called with either a 'DEFAULT' or 'ISO_10646' character kind
4608
+ ! `name` actual argument.
4600
4609
4601
4610
subroutine wrap_json_value_create_integer (json ,me ,val ,name )
4602
4611
@@ -4642,9 +4651,9 @@ end subroutine json_value_create_double
4642
4651
! *****************************************************************************************
4643
4652
! > author: Izaak Beekman
4644
4653
!
4645
- ! A wrapper for [[json_value_create_double]] so that [[json_create_double]] may be
4646
- ! called with an actual argument corresponding to the dummy argument, 'name'
4647
- ! that may be of 'DEFAULT' or 'ISO_10646' character kind.
4654
+ ! A wrapper for [[json_value_create_double]] so that `create_double` method
4655
+ ! may be called with an actual argument corresponding to the dummy argument,
4656
+ ! `name` that may be of 'DEFAULT' or 'ISO_10646' character kind.
4648
4657
4649
4658
subroutine wrap_json_value_create_double (json ,me ,val ,name )
4650
4659
@@ -4690,9 +4699,9 @@ end subroutine json_value_create_string
4690
4699
! *****************************************************************************************
4691
4700
! > author: Izaak Beekman
4692
4701
!
4693
- ! Wrap [[json_value_create_string]] so that [[json_create_string]] may be called with actual
4694
- ! character string arguments for ' name' and ' val' that are BOTH of 'DEFAULT' or
4695
- ! 'ISO_10646' character kind.
4702
+ ! Wrap [[json_value_create_string]] so that `create_string` method may be called
4703
+ ! with actual character string arguments for ` name` and ` val` that are BOTH of
4704
+ ! 'DEFAULT' or ' ISO_10646' character kind.
4696
4705
4697
4706
subroutine wrap_json_value_create_string (json ,me ,val ,name )
4698
4707
@@ -4737,9 +4746,9 @@ end subroutine json_value_create_null
4737
4746
! *****************************************************************************************
4738
4747
! > author: Izaak Beekman
4739
4748
!
4740
- ! Wrap [[json_value_create_null]] so that [[json_create_null]] may be called with an actual
4741
- ! argument corresponding to the dummy argument ' name' that is either of 'DEFAULT' or
4742
- ! 'ISO_10646' character kind.
4749
+ ! Wrap [[json_value_create_null]] so that `create_null` method may be called with
4750
+ ! an actual argument corresponding to the dummy argument ` name` that is either
4751
+ ! of 'DEFAULT' or 'ISO_10646' character kind.
4743
4752
4744
4753
subroutine wrap_json_value_create_null (json ,me ,name )
4745
4754
@@ -4786,9 +4795,9 @@ end subroutine json_value_create_object
4786
4795
! *****************************************************************************************
4787
4796
! > author: Izaak Beekman
4788
4797
!
4789
- ! Wrap [[json_value_create_object]] so that [[json_create_object]] may be called with an actual
4790
- ! argument corresponding to the dummy argument ' name' that is of either 'DEFAULT' or
4791
- ! 'ISO_10646' character kind.
4798
+ ! Wrap [[json_value_create_object]] so that `create_object` method may be called
4799
+ ! with an actual argument corresponding to the dummy argument ` name` that is of
4800
+ ! either 'DEFAULT' or 'ISO_10646' character kind.
4792
4801
4793
4802
subroutine wrap_json_value_create_object (json ,me ,name )
4794
4803
@@ -4832,9 +4841,9 @@ end subroutine json_value_create_array
4832
4841
! *****************************************************************************************
4833
4842
! > author: Izaak Beekman
4834
4843
!
4835
- ! A wrapper for [[json_value_create_array]] so that [[json_create_array]] may be called with
4836
- ! an actual argument, corresponding to the dummy argument ' name', that is either of
4837
- ! 'DEFAULT' or 'ISO_10646' character kind.
4844
+ ! A wrapper for [[json_value_create_array]] so that `create_array` method may be
4845
+ ! called with an actual argument, corresponding to the dummy argument ` name`,
4846
+ ! that is either of 'DEFAULT' or 'ISO_10646' character kind.
4838
4847
4839
4848
subroutine wrap_json_value_create_array (json ,me ,name )
4840
4849
0 commit comments