@@ -5577,9 +5577,6 @@ subroutine json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)
55775577 logical (LK) :: use_brackets ! ! to use '[]' characters for arrays
55785578 logical (LK) :: parent_is_root ! ! if the parent is the root
55795579
5580- ! initialize:
5581- path = CK_' '
5582-
55835580 ! optional input:
55845581 if (present (use_alt_array_tokens)) then
55855582 use_brackets = .not. use_alt_array_tokens
@@ -5597,13 +5594,19 @@ subroutine json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)
55975594
55985595 ! get info about the current variable:
55995596 call json% info(tmp,name= name)
5597+ if (json% path_mode== 2 ) then
5598+ name = encode_rfc6901(name)
5599+ end if
56005600
56015601 ! if tmp a child of an object, or an element of an array
56025602 if (associated (tmp% parent)) then
56035603
56045604 ! get info about the parent:
56055605 call json% info(tmp% parent,var_type= var_type,&
56065606 n_children= n_children,name= parent_name)
5607+ if (json% path_mode== 2 ) then
5608+ parent_name = encode_rfc6901(parent_name)
5609+ end if
56075610
56085611 select case (var_type)
56095612 case (json_array)
@@ -5680,7 +5683,7 @@ subroutine json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)
56805683 end if
56815684
56825685 ! for errors, return blank string:
5683- if (json% exception_thrown) then
5686+ if (json% exception_thrown .or. .not. allocated (path) ) then
56845687 path = CK_' '
56855688 else
56865689 if (json% path_mode== 2 ) then
@@ -5712,14 +5715,14 @@ subroutine add_to_path(str,path_sep)
57125715 select case (json% path_mode)
57135716 case (2 )
57145717 ! in this case, the options are ignored
5715- if (path== CK_ ' ' ) then
5718+ if (.not. allocated ( path) ) then
57165719 path = str
57175720 else
57185721 path = str// slash// path
57195722 end if
57205723 case (1 )
57215724 ! default path format
5722- if (path== CK_ ' ' ) then
5725+ if (.not. allocated ( path) ) then
57235726 path = str
57245727 else
57255728 if (present (path_sep)) then
0 commit comments