@@ -1321,7 +1321,7 @@ end subroutine json_clone
1321
1321
! @note If new data is added to the [[json_value]] type,
1322
1322
! then this would need to be updated.
1323
1323
1324
- recursive subroutine json_value_clone_func (from ,to ,parent ,previous ,next , children , tail )
1324
+ recursive subroutine json_value_clone_func (from ,to ,parent ,previous ,tail )
1325
1325
1326
1326
implicit none
1327
1327
@@ -1330,8 +1330,6 @@ recursive subroutine json_value_clone_func(from,to,parent,previous,next,children
1330
1330
! ! must not already be associated)
1331
1331
type (json_value),pointer ,optional :: parent ! ! to%parent
1332
1332
type (json_value),pointer ,optional :: previous ! ! to%previous
1333
- type (json_value),pointer ,optional :: next ! ! to%next
1334
- type (json_value),pointer ,optional :: children ! ! to%children
1335
1333
logical ,optional :: tail ! ! if "to" is the tail of
1336
1334
! ! its parent's children
1337
1335
@@ -1352,33 +1350,28 @@ recursive subroutine json_value_clone_func(from,to,parent,previous,next,children
1352
1350
to % var_type = from% var_type
1353
1351
to % n_children = from% n_children
1354
1352
1355
- ! allocate and associate the pointers as necessary:
1356
-
1357
- if (present (parent)) to % parent = > parent
1358
- if (present (previous)) to % previous = > previous
1359
- if (present (next)) to % next = > next
1360
- if (present (children)) to % children = > children
1353
+ ! allocate and associate the pointers as necessary:
1354
+ if (present (parent)) to % parent = > parent
1355
+ if (present (previous)) to % previous = > previous
1361
1356
if (present (tail)) then
1362
1357
if (tail .and. associated (to % parent)) to % parent% tail = > to
1363
1358
end if
1364
1359
1365
1360
if (associated (from% next) .and. associated (to % parent)) then
1366
1361
! we only clone the next entry in an array
1367
1362
! if the parent has also been cloned
1368
- allocate (to % next)
1369
- call json_value_clone_func(from% next,&
1370
- to % next,&
1371
- previous= to ,&
1372
- parent= to % parent,&
1373
- tail= (.not. associated (from% next% next)))
1363
+ call json_value_clone_func(from = from% next,&
1364
+ to = to % next,&
1365
+ previous = to ,&
1366
+ parent = to % parent,&
1367
+ tail = (.not. associated (from% next% next)))
1374
1368
end if
1375
1369
1376
1370
if (associated (from% children)) then
1377
- allocate (to % children)
1378
- call json_value_clone_func(from% children,&
1379
- to % children,&
1380
- parent= to ,&
1381
- tail= (.not. associated (from% children% next)))
1371
+ call json_value_clone_func(from = from% children,&
1372
+ to = to % children,&
1373
+ parent = to ,&
1374
+ tail = (.not. associated (from% children% next)))
1382
1375
end if
1383
1376
1384
1377
end if
@@ -8148,8 +8141,13 @@ subroutine json_get_integer(json, me, value)
8148
8141
value = me% int_value
8149
8142
else
8150
8143
if (json% strict_type_checking) then
8151
- call json% throw_exception(' Error in json_get_integer:' // &
8152
- ' Unable to resolve value to integer: ' // me% name)
8144
+ if (allocated (me% name)) then
8145
+ call json% throw_exception(' Error in json_get_integer:' // &
8146
+ ' Unable to resolve value to integer: ' // me% name)
8147
+ else
8148
+ call json% throw_exception(' Error in json_get_integer:' // &
8149
+ ' Unable to resolve value to integer' )
8150
+ end if
8153
8151
else
8154
8152
! type conversions
8155
8153
select case (me% var_type)
@@ -8165,13 +8163,24 @@ subroutine json_get_integer(json, me, value)
8165
8163
call string_to_integer(me% str_value,value,status_ok)
8166
8164
if (.not. status_ok) then
8167
8165
value = 0_IK
8168
- call json% throw_exception(' Error in json_get_integer:' // &
8169
- ' Unable to convert string value to integer: me.' // &
8170
- me% name// ' = ' // trim (me% str_value))
8166
+ if (allocated (me% name)) then
8167
+ call json% throw_exception(' Error in json_get_integer:' // &
8168
+ ' Unable to convert string value to integer: ' // &
8169
+ me% name// ' = ' // trim (me% str_value))
8170
+ else
8171
+ call json% throw_exception(' Error in json_get_integer:' // &
8172
+ ' Unable to convert string value to integer: ' // &
8173
+ trim (me% str_value))
8174
+ end if
8171
8175
end if
8172
8176
case default
8173
- call json% throw_exception(' Error in json_get_integer:' // &
8174
- ' Unable to resolve value to integer: ' // me% name)
8177
+ if (allocated (me% name)) then
8178
+ call json% throw_exception(' Error in json_get_integer:' // &
8179
+ ' Unable to resolve value to integer: ' // me% name)
8180
+ else
8181
+ call json% throw_exception(' Error in json_get_integer:' // &
8182
+ ' Unable to resolve value to integer' )
8183
+ end if
8175
8184
end select
8176
8185
end if
8177
8186
end if
@@ -8361,8 +8370,13 @@ subroutine json_get_real(json, me, value)
8361
8370
value = me% dbl_value
8362
8371
else
8363
8372
if (json% strict_type_checking) then
8364
- call json% throw_exception(' Error in json_get_real:' // &
8365
- ' Unable to resolve value to real: ' // me% name)
8373
+ if (allocated (me% name)) then
8374
+ call json% throw_exception(' Error in json_get_real:' // &
8375
+ ' Unable to resolve value to real: ' // me% name)
8376
+ else
8377
+ call json% throw_exception(' Error in json_get_real:' // &
8378
+ ' Unable to resolve value to real' )
8379
+ end if
8366
8380
else
8367
8381
! type conversions
8368
8382
select case (me% var_type)
@@ -8378,9 +8392,15 @@ subroutine json_get_real(json, me, value)
8378
8392
call string_to_real(me% str_value,json% use_quiet_nan,value,status_ok)
8379
8393
if (.not. status_ok) then
8380
8394
value = 0.0_RK
8381
- call json% throw_exception(' Error in json_get_real:' // &
8382
- ' Unable to convert string value to real: me.' // &
8383
- me% name// ' = ' // trim (me% str_value))
8395
+ if (allocated (me% name)) then
8396
+ call json% throw_exception(' Error in json_get_real:' // &
8397
+ ' Unable to convert string value to real: ' // &
8398
+ me% name// ' = ' // trim (me% str_value))
8399
+ else
8400
+ call json% throw_exception(' Error in json_get_real:' // &
8401
+ ' Unable to convert string value to real: ' // &
8402
+ trim (me% str_value))
8403
+ end if
8384
8404
end if
8385
8405
case (json_null)
8386
8406
if (ieee_support_nan(value) .and. json% null_to_real_mode/= 1_IK ) then
@@ -8395,13 +8415,22 @@ subroutine json_get_real(json, me, value)
8395
8415
value = 0.0_RK
8396
8416
end select
8397
8417
else
8398
- call json% throw_exception(' Error in json_get_real:' // &
8399
- ' Cannot convert null to NaN: ' // me% name)
8418
+ if (allocated (me% name)) then
8419
+ call json% throw_exception(' Error in json_get_real:' // &
8420
+ ' Cannot convert null to NaN: ' // me% name)
8421
+ else
8422
+ call json% throw_exception(' Error in json_get_real:' // &
8423
+ ' Cannot convert null to NaN' )
8424
+ end if
8400
8425
end if
8401
8426
case default
8402
-
8403
- call json% throw_exception(' Error in json_get_real:' // &
8404
- ' Unable to resolve value to real: ' // me% name)
8427
+ if (allocated (me% name)) then
8428
+ call json% throw_exception(' Error in json_get_real:' // &
8429
+ ' Unable to resolve value to real: ' // me% name)
8430
+ else
8431
+ call json% throw_exception(' Error in json_get_real:' // &
8432
+ ' Unable to resolve value to real' )
8433
+ end if
8405
8434
end select
8406
8435
end if
8407
8436
end if
@@ -8851,9 +8880,14 @@ subroutine json_get_logical(json, me, value)
8851
8880
value = me% log_value
8852
8881
else
8853
8882
if (json% strict_type_checking) then
8854
- call json% throw_exception(' Error in json_get_logical: ' // &
8855
- ' Unable to resolve value to logical: ' // &
8856
- me% name)
8883
+ if (allocated (me% name)) then
8884
+ call json% throw_exception(' Error in json_get_logical: ' // &
8885
+ ' Unable to resolve value to logical: ' // &
8886
+ me% name)
8887
+ else
8888
+ call json% throw_exception(' Error in json_get_logical: ' // &
8889
+ ' Unable to resolve value to logical' )
8890
+ end if
8857
8891
else
8858
8892
! type conversions
8859
8893
select case (me% var_type)
@@ -8864,9 +8898,14 @@ subroutine json_get_logical(json, me, value)
8864
8898
case (json_string)
8865
8899
value = (me% str_value == true_str)
8866
8900
case default
8867
- call json% throw_exception(' Error in json_get_logical: ' // &
8868
- ' Unable to resolve value to logical: ' // &
8869
- me% name)
8901
+ if (allocated (me% name)) then
8902
+ call json% throw_exception(' Error in json_get_logical: ' // &
8903
+ ' Unable to resolve value to logical: ' // &
8904
+ me% name)
8905
+ else
8906
+ call json% throw_exception(' Error in json_get_logical: ' // &
8907
+ ' Unable to resolve value to logical' )
8908
+ end if
8870
8909
end select
8871
8910
end if
8872
8911
end if
@@ -9053,8 +9092,13 @@ subroutine json_get_string(json, me, value)
9053
9092
else
9054
9093
9055
9094
if (json% strict_type_checking) then
9056
- call json% throw_exception(' Error in json_get_string:' // &
9057
- ' Unable to resolve value to string: ' // me% name)
9095
+ if (allocated (me% name)) then
9096
+ call json% throw_exception(' Error in json_get_string:' // &
9097
+ ' Unable to resolve value to string: ' // me% name)
9098
+ else
9099
+ call json% throw_exception(' Error in json_get_string:' // &
9100
+ ' Unable to resolve value to string' )
9101
+ end if
9058
9102
else
9059
9103
9060
9104
select case (me% var_type)
@@ -9101,11 +9145,14 @@ subroutine json_get_string(json, me, value)
9101
9145
value = null_str
9102
9146
9103
9147
case default
9104
-
9105
- call json% throw_exception(' Error in json_get_string: ' // &
9106
- ' Unable to resolve value to characters: ' // &
9107
- me% name)
9108
-
9148
+ if (allocated (me% name)) then
9149
+ call json% throw_exception(' Error in json_get_string: ' // &
9150
+ ' Unable to resolve value to characters: ' // &
9151
+ me% name)
9152
+ else
9153
+ call json% throw_exception(' Error in json_get_string: ' // &
9154
+ ' Unable to resolve value to characters' )
9155
+ end if
9109
9156
end select
9110
9157
9111
9158
end if
0 commit comments