@@ -503,6 +503,15 @@ end subroutine traverse_callback_func
503503 end interface json_get_child
504504 ! *************************************************************************************
505505
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+
506515 ! *************************************************************************************
507516 ! >
508517 ! Add objects to a linked list of [[json_value]]s.
@@ -827,6 +836,7 @@ end subroutine traverse_callback_func
827836 public :: json_failed ! check for error
828837 public :: json_get ! get data from the JSON structure
829838 public :: json_get_child ! get a child of a json_value
839+ public :: json_get_parent ! get the parent of a json_value
830840 public :: json_info ! get info about a json_value
831841 public :: json_initialize ! to initialize the module
832842 public :: json_parse ! read a JSON file and populate the structure
@@ -3236,7 +3246,30 @@ pure function json_count(me) result(count)
32363246
32373247 count = me% n_children
32383248
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
32403273! *****************************************************************************************
32413274
32423275! *****************************************************************************************
0 commit comments