Inserts element
after the idx
-th child of p
,
and updates the JSON structure accordingly. This is just
a wrapper for json_value_insert_after.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(json_core), | intent(inout) | :: | json | |||
type(json_value), | pointer | :: | p | a JSON object or array. |
||
integer(kind=IK), | intent(in) | :: | idx | the index of the child of |
||
type(json_value), | pointer | :: | element | the element to insert |
subroutine json_value_insert_after_child_by_index(json,p,idx,element)
implicit none
class(json_core),intent(inout) :: json
type(json_value),pointer :: p !! a JSON object or array.
integer(IK),intent(in) :: idx !! the index of the child of `p` to
!! insert the new element after
type(json_value),pointer :: element !! the element to insert
type(json_value),pointer :: tmp !! for getting the `idx`-th child of `p`
if (.not. json%exception_thrown) then
! get the idx-th child of p:
call json%get_child(p,idx,tmp)
! call json_value_insert_after:
if (.not. json%exception_thrown) call json%insert_after(tmp,element)
end if
end subroutine json_value_insert_after_child_by_index