@@ -5305,9 +5305,6 @@ subroutine json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)
53055305 logical (LK) :: use_brackets ! ! to use '[]' characters for arrays
53065306 logical (LK) :: parent_is_root ! ! if the parent is the root
53075307
5308- ! initialize:
5309- path = CK_' '
5310-
53115308 ! optional input:
53125309 if (present (use_alt_array_tokens)) then
53135310 use_brackets = .not. use_alt_array_tokens
@@ -5325,13 +5322,19 @@ subroutine json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)
53255322
53265323 ! get info about the current variable:
53275324 call json% info(tmp,name= name)
5325+ if (json% path_mode== 2 ) then
5326+ name = encode_rfc6901(name)
5327+ end if
53285328
53295329 ! if tmp a child of an object, or an element of an array
53305330 if (associated (tmp% parent)) then
53315331
53325332 ! get info about the parent:
53335333 call json% info(tmp% parent,var_type= var_type,&
53345334 n_children= n_children,name= parent_name)
5335+ if (json% path_mode== 2 ) then
5336+ parent_name = encode_rfc6901(parent_name)
5337+ end if
53355338
53365339 select case (var_type)
53375340 case (json_array)
@@ -5408,7 +5411,7 @@ subroutine json_get_path(json, p, path, found, use_alt_array_tokens, path_sep)
54085411 end if
54095412
54105413 ! for errors, return blank string:
5411- if (json% exception_thrown) then
5414+ if (json% exception_thrown .or. .not. allocated (path) ) then
54125415 path = CK_' '
54135416 else
54145417 if (json% path_mode== 2 ) then
@@ -5440,14 +5443,14 @@ subroutine add_to_path(str,path_sep)
54405443 select case (json% path_mode)
54415444 case (2 )
54425445 ! in this case, the options are ignored
5443- if (path== CK_ ' ' ) then
5446+ if (.not. allocated ( path) ) then
54445447 path = str
54455448 else
54465449 path = str// slash// path
54475450 end if
54485451 case (1 )
54495452 ! default path format
5450- if (path== CK_ ' ' ) then
5453+ if (.not. allocated ( path) ) then
54515454 path = str
54525455 else
54535456 if (present (path_sep)) then
0 commit comments