json_get_vec_by_path.inc 767 Bytes
Newer Older
Victor Yu's avatar
Victor Yu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    type(json_value),pointer :: p

    if ( json%exception_thrown ) then
        if (present(default)) vec = default
        call flag_not_found(found)
        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 '//routine//':'//&
                                  ' Unable to resolve path: '// trim(path),found)
    else
        call json%get(p,vec)
    end if

    if ( json%exception_thrown ) then
        if ( present(found) .or. present(default)) then
            call flag_not_found(found)
            if (present(default)) vec = default
            call json%clear_exceptions()
        end if
    else
        if ( present(found) ) found = .true.
    end if