@@ -375,10 +375,6 @@ module json_value_module
375
375
procedure :: json_value_destroy
376
376
procedure :: destroy_json_core
377
377
378
- ! >
379
- ! Remove a [[json_value]] from a linked-list structure.
380
- procedure ,public :: remove = > json_value_remove
381
-
382
378
! >
383
379
! If the child variable is present, then remove it.
384
380
generic,public :: remove_if_present = > MAYBEWRAP(json_value_remove_if_present)
@@ -491,23 +487,17 @@ module json_value_module
491
487
procedure :: json_parse_file
492
488
procedure :: MAYBEWRAP(json_parse_string)
493
489
494
- ! >
495
- ! Swap two [[json_value]] pointers in a structure
496
- ! (or two different structures).
497
- generic,public :: swap = > json_value_swap
498
- procedure :: json_value_swap
499
-
500
- ! >
501
- ! Check if a [[json_value]] is a child of another.
502
- generic,public :: is_child_of = > json_value_is_child_of
503
- procedure :: json_value_is_child_of
504
-
505
490
! >
506
491
! Throw an exception.
507
492
generic,public :: throw_exception = > MAYBEWRAP(json_throw_exception)
508
493
procedure :: MAYBEWRAP(json_throw_exception)
509
494
510
- ! public routines:
495
+ ! >
496
+ ! Rename a [[json_value]] variable.
497
+ generic,public :: rename = > MAYBEWRAP(json_value_rename)
498
+ procedure :: MAYBEWRAP(json_value_rename)
499
+
500
+ procedure ,public :: remove = > json_value_remove ! ! Remove a [[json_value]] from a linked-list structure.
511
501
procedure ,public :: check_for_errors = > json_check_for_errors ! ! check for error and get error message
512
502
procedure ,public :: clear_exceptions = > json_clear_exceptions ! ! clear exceptions
513
503
procedure ,public :: count = > json_count ! ! count the number of children
@@ -521,6 +511,9 @@ module json_value_module
521
511
procedure ,public :: initialize = > json_initialize ! ! to initialize some parsing parameters
522
512
procedure ,public :: traverse = > json_traverse ! ! to traverse all elements of a JSON structure
523
513
procedure ,public :: print_error_message = > json_print_error_message ! ! simply routine to print error messages
514
+ procedure ,public :: swap = > json_value_swap ! ! Swap two [[json_value]] pointers
515
+ ! ! in a structure (or two different structures).
516
+ procedure ,public :: is_child_of = > json_value_is_child_of ! ! Check if a [[json_value]] is a child of another.
524
517
525
518
! other private routines:
526
519
procedure :: json_value_print
@@ -914,11 +907,55 @@ subroutine json_info(json,p,var_type,n_children,name)
914
907
915
908
if (present (var_type)) var_type = p% var_type
916
909
if (present (n_children)) n_children = json% count (p)
917
- if (present (name)) name = p% name
910
+ if (present (name)) then
911
+ if (allocated (p% name)) then
912
+ name = p% name
913
+ else
914
+ name = ' '
915
+ end if
916
+ end if
918
917
919
918
end subroutine json_info
920
919
! *****************************************************************************************
921
920
921
+ ! *****************************************************************************************
922
+ ! > author: Jacob Williams
923
+ ! date: 4/29/2016
924
+ !
925
+ ! Rename a [[json_value]].
926
+
927
+ subroutine json_value_rename (json ,p ,name )
928
+
929
+ implicit none
930
+
931
+ class(json_core),intent (inout ) :: json
932
+ type (json_value),pointer ,intent (in ) :: p
933
+ character (kind= CK,len=* ),intent (in ) :: name ! ! new variable name
934
+
935
+ p% name = name
936
+
937
+ end subroutine json_value_rename
938
+ ! *****************************************************************************************
939
+
940
+ ! *****************************************************************************************
941
+ ! > author: Jacob Williams
942
+ ! date: 4/29/2016
943
+ !
944
+ ! Alternate version of [[json_value_rename]], where `name` is kind=CDK.
945
+
946
+ subroutine wrap_json_value_rename (json ,p ,name )
947
+
948
+ implicit none
949
+
950
+ class(json_core),intent (inout ) :: json
951
+ type (json_value),pointer ,intent (in ) :: p
952
+ character (kind= CDK,len=* ),intent (in ) :: name ! ! new variable name
953
+
954
+ call json% rename(p,to_unicode(name))
955
+
956
+ end subroutine wrap_json_value_rename
957
+ ! *****************************************************************************************
958
+
922
959
! *****************************************************************************************
923
960
! > author: Jacob Williams
924
961
! date: 12/4/2013
0 commit comments