@@ -2511,7 +2511,8 @@ end subroutine json_value_get_by_index
2511
2511
!
2512
2512
! NOTES
2513
2513
! It is a case-sensitive search, and the name string is not trimmed,
2514
- ! So, for example, 'a ' /= 'A ' /= 'a '
2514
+ ! So, for example, 'a ' /= 'A ' /= 'a '
2515
+ ! Note that the name is not parsed like it is in json_get_by_path.
2515
2516
!
2516
2517
! SOURCE
2517
2518
@@ -2523,7 +2524,7 @@ subroutine json_value_get_by_name_chars(this, name, p)
2523
2524
character (kind= CK,len=* ),intent (in ) :: name
2524
2525
type (json_value),pointer :: p
2525
2526
2526
- integer (IK) :: i
2527
+ integer (IK) :: i,n_children
2527
2528
2528
2529
nullify(p)
2529
2530
@@ -2532,11 +2533,13 @@ subroutine json_value_get_by_name_chars(this, name, p)
2532
2533
if (associated (this)) then
2533
2534
2534
2535
if (this% var_type== json_object) then
2535
- do i= 1 , json_count(this)
2536
- call json_get_child(this, i, p)
2536
+ n_children = json_count(this)
2537
+ p = > this% children ! start with first one
2538
+ do i= 1 , n_children
2537
2539
if (allocated (p% name)) then
2538
2540
if (p% name == name) return
2539
2541
end if
2542
+ p = > p% next
2540
2543
end do
2541
2544
end if
2542
2545
@@ -2924,19 +2927,23 @@ end subroutine json_value_print
2924
2927
! DESCRIPTION
2925
2928
! Returns the json_value pointer given the path string.
2926
2929
!
2927
- ! NOTES
2928
- ! Path syntax is:
2929
- ! $ root
2930
- ! @ this
2931
- ! . child object member
2932
- ! [] or () child array element
2933
- !
2934
2930
! EXAMPLE
2935
2931
! type(json_value),pointer :: dat,p
2936
2932
! logical :: found
2937
2933
! ...
2938
2934
! call json_get(dat,'data(2).version',p,found)
2939
2935
!
2936
+ ! NOTES
2937
+ ! The following special characters are used to denote paths:
2938
+ ! $ - root
2939
+ ! @ - this
2940
+ ! . - child object member
2941
+ ! [] or () - child array element
2942
+ !
2943
+ ! Thus, if any of these characters are present in the name key,
2944
+ ! this routine cannot be used to get the value.
2945
+ ! In that case, the json_get_child routines would need to be used.
2946
+ !
2940
2947
! SOURCE
2941
2948
2942
2949
subroutine json_get_by_path (this , path , p , found )
0 commit comments