Skip to content

Commit 2c96de6

Browse files
committed
added methods for adding null variables.
1 parent a1bac70 commit 2c96de6

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/json_value_module.F90

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ module json_value_module
227227
!>
228228
! Add objects to a linked list of [[json_value]]s.
229229
generic,public :: add => json_value_add_member, &
230+
MAYBEWRAP(json_value_add_null), &
230231
MAYBEWRAP(json_value_add_integer), &
231232
MAYBEWRAP(json_value_add_integer_vec), &
232233
MAYBEWRAP(json_value_add_double), &
@@ -244,6 +245,7 @@ module json_value_module
244245

245246
procedure,private :: json_value_add_member
246247
procedure,private :: MAYBEWRAP(json_value_add_integer)
248+
procedure,private :: MAYBEWRAP(json_value_add_null)
247249
procedure,private :: MAYBEWRAP(json_value_add_integer_vec)
248250
procedure,private :: MAYBEWRAP(json_value_add_double)
249251
procedure,private :: MAYBEWRAP(json_value_add_double_vec)
@@ -2581,6 +2583,49 @@ subroutine wrap_json_value_add_double_vec(json, p, name, val)
25812583
end subroutine wrap_json_value_add_double_vec
25822584
!*****************************************************************************************
25832585

2586+
!*****************************************************************************************
2587+
!>
2588+
! Add a NULL value child to the [[json_value]] variable
2589+
!
2590+
!@note This routine is part of the public API that can be
2591+
! used to build a JSON structure using [[json_value]] pointers.
2592+
2593+
subroutine json_value_add_null(json, p, name)
2594+
2595+
implicit none
2596+
2597+
class(json_core),intent(inout) :: json
2598+
type(json_value),pointer :: p
2599+
character(kind=CK,len=*),intent(in) :: name
2600+
2601+
type(json_value),pointer :: var
2602+
2603+
!create the variable:
2604+
call json%create_null(var,name)
2605+
2606+
!add it:
2607+
call json%add(p, var)
2608+
2609+
end subroutine json_value_add_null
2610+
!*****************************************************************************************
2611+
2612+
!*****************************************************************************************
2613+
!>
2614+
! Alternate version of [[json_value_add_null]] where `name` is kind=CDK.
2615+
2616+
subroutine wrap_json_value_add_null(json, p, name)
2617+
2618+
implicit none
2619+
2620+
class(json_core),intent(inout) :: json
2621+
type(json_value),pointer :: p
2622+
character(kind=CDK,len=*),intent(in) :: name !! name of the variable
2623+
2624+
call json%add(p, to_unicode(name))
2625+
2626+
end subroutine wrap_json_value_add_null
2627+
!*****************************************************************************************
2628+
25842629
!*****************************************************************************************
25852630
!> author: Jacob Williams
25862631
! date: 1/20/2014

0 commit comments

Comments
 (0)