Rename a json_value, given the path.
this is a wrapper for json_value_rename.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
type(json_value), | intent(in), | pointer | :: | me | ||
character(kind=CK,len=*), | intent(in) | :: | path | path to the variable to rename |
||
character(kind=CK,len=*), | intent(in) | :: | name | the new name |
||
logical(kind=LK), | intent(out), | optional | :: | found | if there were no errors |
subroutine json_rename_by_path(json, me, path, name, found)
implicit none
class(json_core),intent(inout) :: json
type(json_value),pointer,intent(in) :: me
character(kind=CK,len=*),intent(in) :: path !! path to the variable to rename
character(kind=CK,len=*),intent(in) :: name !! the new name
logical(LK),intent(out),optional :: found !! if there were no errors
type(json_value),pointer :: p
if ( json%exception_thrown ) then
if ( present(found) ) found = .false.
return
end if
nullify(p)
call json%get(me=me, path=path, p=p)
if (.not. associated(p)) then
call json%throw_exception('Error in json_rename_by_path:'//&
' Unable to resolve path: '//trim(path),found)
else
call json%rename(p,name)
nullify(p)
end if
if (json%exception_thrown) then
if (present(found)) then
found = .false.
call json%clear_exceptions()
end if
else
if (present(found)) found = .true.
end if
end subroutine json_rename_by_path