@@ -503,6 +503,15 @@ end subroutine traverse_callback_func
503
503
end interface json_get_child
504
504
! *************************************************************************************
505
505
506
+ ! *************************************************************************************
507
+ ! >
508
+ ! Get the parent.
509
+ ! Returns a [[json_value]] pointer.
510
+ interface json_get_parent
511
+ module procedure json_value_get_parent
512
+ end interface json_get_parent
513
+ ! *************************************************************************************
514
+
506
515
! *************************************************************************************
507
516
! >
508
517
! Add objects to a linked list of [[json_value]]s.
@@ -827,6 +836,7 @@ end subroutine traverse_callback_func
827
836
public :: json_failed ! check for error
828
837
public :: json_get ! get data from the JSON structure
829
838
public :: json_get_child ! get a child of a json_value
839
+ public :: json_get_parent ! get the parent of a json_value
830
840
public :: json_info ! get info about a json_value
831
841
public :: json_initialize ! to initialize the module
832
842
public :: json_parse ! read a JSON file and populate the structure
@@ -3236,7 +3246,30 @@ pure function json_count(me) result(count)
3236
3246
3237
3247
count = me% n_children
3238
3248
3239
- end function json_count
3249
+ end function json_count
3250
+ ! *****************************************************************************************
3251
+
3252
+ ! *****************************************************************************************
3253
+ ! > author: Jacob Williams
3254
+ ! date: 10/16/2015
3255
+ !
3256
+ ! Returns a pointer to the parent of a [[json_value]].
3257
+ ! If there is no parent, then a null() pointer is returned.
3258
+
3259
+ subroutine json_value_get_parent (me ,p )
3260
+
3261
+ implicit none
3262
+
3263
+ type (json_value),pointer ,intent (in ) :: me ! ! JSON object
3264
+ type (json_value),pointer :: p ! ! pointer to the parent
3265
+
3266
+ if (associated (me% parent)) then
3267
+ p = > me% parent
3268
+ else
3269
+ p = > null ()
3270
+ end if
3271
+
3272
+ end subroutine json_value_get_parent
3240
3273
! *****************************************************************************************
3241
3274
3242
3275
! *****************************************************************************************
0 commit comments