Alternate version of json_get_alloc_string_vec where input is the path.
This is an alternate version of json_get_string_vec_by_path. This one returns an allocatable length character (where the string length is the maximum length of any element in the array). It also returns an integer array of the actual sizes of the strings in the JSON structure.
An alternative to using this routine is to use json_get_array with a callback function that gets the string from each element and populates a user-defined string type.
If the default
argument is used, and default_ilen
is not present,
then ilen
will just be returned as the length of the default
dummy
argument (all elements with the same length).
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 | |||
character(kind=CK,len=:), | intent(out), | dimension(:), allocatable | :: | vec | ||
integer(kind=IK), | intent(out), | dimension(:), allocatable | :: | ilen | the actual length of each character string in the array |
|
logical(kind=LK), | intent(out), | optional | :: | found | ||
character(kind=CK,len=*), | intent(in), | optional | dimension(:) | :: | default | |
integer(kind=IK), | intent(in), | optional | dimension(:) | :: | default_ilen | the actual
length of |
subroutine json_get_alloc_string_vec_by_path(json,me,path,vec,ilen,found,default,default_ilen)
implicit none
class(json_core),intent(inout) :: json
type(json_value),pointer,intent(in) :: me
character(kind=CK,len=*),intent(in) :: path
character(kind=CK,len=:),dimension(:),allocatable,intent(out) :: vec
integer(IK),dimension(:),allocatable,intent(out) :: ilen !! the actual length
!! of each character
!! string in the array
logical(LK),intent(out),optional :: found
character(kind=CK,len=*),dimension(:),intent(in),optional :: default
integer(IK),dimension(:),intent(in),optional :: default_ilen !! the actual
!! length of `default`
character(kind=CK,len=*),parameter :: routine = CK_'json_get_alloc_string_vec_by_path'
#include "json_get_vec_by_path_alloc.inc"
end subroutine json_get_alloc_string_vec_by_path