@@ -223,7 +223,8 @@ module json_module
223
223
224
224
private
225
225
226
- type (json_value), pointer :: p = > null () ! the JSON structure read from the file
226
+ ! the JSON structure read from the file:
227
+ type (json_value), pointer :: p = > null ()
227
228
228
229
contains
229
230
@@ -281,9 +282,9 @@ end subroutine array_callback_func
281
282
! Get a child, either by index or name string.
282
283
!
283
284
! SOURCE
284
- interface json_value_get ! consider renaming this json_value_get_child
285
- module procedure get_by_index
286
- module procedure get_by_name_chars
285
+ interface json_value_get ! consider renaming this json_value_get_child
286
+ module procedure json_value_get_by_index
287
+ module procedure json_value_get_by_name_chars
287
288
end interface json_value_get
288
289
! *************************************************************************************
289
290
@@ -413,9 +414,7 @@ end subroutine array_callback_func
413
414
! json_remove
414
415
!
415
416
! DESCRIPTION
416
- ! Remove and destroy a json_value (and all its children)
417
- ! from a linked-list structure.
418
- ! The rest of the structure is preserved.
417
+ ! Remove a json_value from a linked-list structure.
419
418
!
420
419
! SOURCE
421
420
interface json_remove
@@ -1078,7 +1077,7 @@ end subroutine json_clear_exceptions
1078
1077
! *****************************************************************************************
1079
1078
1080
1079
! *****************************************************************************************
1081
- ! ****f * json_module/throw_exception
1080
+ ! ****if * json_module/throw_exception
1082
1081
!
1083
1082
! NAME
1084
1083
! throw_exception
@@ -1269,9 +1268,9 @@ recursive subroutine json_value_destroy(this)
1269
1268
1270
1269
call this% data % destroy()
1271
1270
1272
- if (associated (this% children)) call json_value_destroy(this% children)
1271
+ if (associated (this% children)) call json_value_destroy(this% children)
1273
1272
1274
- if (associated (this% next)) call json_value_destroy(this% next)
1273
+ if (associated (this% next)) call json_value_destroy(this% next)
1275
1274
1276
1275
deallocate (this)
1277
1276
@@ -1290,25 +1289,25 @@ end subroutine json_value_destroy
1290
1289
!
1291
1290
! DESCRIPTION
1292
1291
! Remove a json_value (and all its children)
1293
- ! from a linked-list structure, preserving the rest of the structure.
1294
- !
1292
+ ! from a linked-list structure, preserving the rest of the structure.
1295
1293
! If destroy is not present, it is also destroyed.
1294
+ ! If destroy is present and true, it is destroyed.
1296
1295
! If destroy is present and false, it is not destroyed.
1297
1296
!
1298
1297
! EXAMPLE
1299
1298
!
1300
1299
! !to extract an object from one json structure, and add it to another:
1301
1300
! type(json_value),pointer :: json1,json2,p
1302
1301
! logical :: found
1303
- ! ... create json1 and json2
1302
+ ! [ create and populate json1 and json2]
1304
1303
! call json_get(json1,'name',p,found) ! get pointer to name element of json1
1305
1304
! call json_remove(p,destroy=.false.) ! remove it from json1 (don't destroy)
1306
1305
! call json_value_add(json2,p) ! add it to json2
1307
1306
!
1308
1307
! !to remove an object from a json structure (and destroy it)
1309
1308
! type(json_value),pointer :: json1,p
1310
1309
! logical :: found
1311
- ! ... create json1
1310
+ ! [ create and populate json1]
1312
1311
! call json_get(json1,'name',p,found) ! get pointer to name element of json1
1313
1312
! call json_remove(p) ! remove and destroy it
1314
1313
!
@@ -2128,17 +2127,17 @@ end function json_value_count
2128
2127
! *****************************************************************************************
2129
2128
2130
2129
! *****************************************************************************************
2131
- ! ****f* json_module/get_by_index
2130
+ ! ****f* json_module/json_value_get_by_index
2132
2131
!
2133
2132
! NAME
2134
- ! get_by_index
2133
+ ! json_value_get_by_index
2135
2134
!
2136
2135
! DESCRIPTION
2137
2136
! Returns a child in the object given the index.
2138
2137
!
2139
2138
! SOURCE
2140
2139
2141
- subroutine get_by_index (this , idx , p )
2140
+ subroutine json_value_get_by_index (this , idx , p )
2142
2141
2143
2142
implicit none
2144
2143
@@ -2161,7 +2160,7 @@ subroutine get_by_index(this, idx, p)
2161
2160
if (associated (p% next)) then
2162
2161
p = > p% next
2163
2162
else
2164
- call throw_exception(' Error in get_by_index :' // &
2163
+ call throw_exception(' Error in json_value_get_by_index :' // &
2165
2164
' p%next is not associated.' )
2166
2165
return
2167
2166
end if
@@ -2170,28 +2169,28 @@ subroutine get_by_index(this, idx, p)
2170
2169
2171
2170
else
2172
2171
2173
- call throw_exception(' Error in get_by_index :' // &
2172
+ call throw_exception(' Error in json_value_get_by_index :' // &
2174
2173
' this%children is not associated.' )
2175
2174
2176
2175
end if
2177
2176
2178
2177
end if
2179
2178
2180
- end subroutine get_by_index
2179
+ end subroutine json_value_get_by_index
2181
2180
! *****************************************************************************************
2182
2181
2183
2182
! *****************************************************************************************
2184
- ! ****f* json_module/get_by_name_chars
2183
+ ! ****f* json_module/json_value_get_by_name_chars
2185
2184
!
2186
2185
! NAME
2187
- ! get_by_name_chars
2186
+ ! json_value_get_by_name_chars
2188
2187
!
2189
2188
! DESCRIPTION
2190
2189
! Returns a child in the object given the name string.
2191
2190
!
2192
2191
! SOURCE
2193
2192
2194
- subroutine get_by_name_chars (this , name , p )
2193
+ subroutine json_value_get_by_name_chars (this , name , p )
2195
2194
2196
2195
implicit none
2197
2196
@@ -2220,12 +2219,13 @@ subroutine get_by_name_chars(this, name, p)
2220
2219
nullify(p)
2221
2220
2222
2221
else
2223
- call throw_exception(' Error in get_by_name_chars: pointer is not associated.' )
2222
+ call throw_exception(' Error in json_value_get_by_name_chars: ' // &
2223
+ ' pointer is not associated.' )
2224
2224
end if
2225
2225
2226
2226
end if
2227
2227
2228
- end subroutine get_by_name_chars
2228
+ end subroutine json_value_get_by_name_chars
2229
2229
! *****************************************************************************************
2230
2230
2231
2231
! *****************************************************************************************
@@ -3491,9 +3491,11 @@ end subroutine json_get_char_vec
3491
3491
! json_get_array
3492
3492
!
3493
3493
! DESCRIPTION
3494
- ! Get an array from a json_value.
3495
3494
! This routine calls the user-supplied array_callback subroutine
3496
3495
! for each element in the array.
3496
+ ! Note: for integer, double, logical, and character arrays,
3497
+ ! a higher-level routine is provided (see json_get), so
3498
+ ! this routine does not have to be used for those cases.
3497
3499
!
3498
3500
! SOURCE
3499
3501
@@ -3537,7 +3539,8 @@ subroutine json_get_array(this, path, array_callback, found)
3537
3539
end do
3538
3540
case default
3539
3541
call throw_exception(' Error in json_get_array:' // &
3540
- ' Resolved value is not an array. ' // trim (path))
3542
+ ' Resolved value is not an array. ' // &
3543
+ trim (path))
3541
3544
end select
3542
3545
! end associate
3543
3546
0 commit comments