@@ -276,15 +276,27 @@ module json_module
276276 !
277277 ! # Example
278278 !
279+ ! The following test program:
279280 ! ```fortran
281+ ! program test
282+ ! use json_module
283+ ! implicit none
280284 ! type(json_value),pointer :: p
281- ! call json_create_object(p,'') !root
282- ! call json_add(p,'year',1805)
283- ! call json_add(p,'value',1.0d0)
284- ! call json_print(p,'test.json')
285- ! call json_destroy(p)
285+ ! call json_initialize() !initialize the module
286+ ! call json_create_object(p,'') !create the root
287+ ! call json_add(p,'year',1805) !add some data
288+ ! call json_add(p,'value',1.0d0) !add some data
289+ ! call json_print(p,'test.json') !write it to a file
290+ ! call json_destroy(p) !cleanup
291+ ! end program test
292+ ! ```
293+ ! Produces the JSON file **test.json**:
294+ ! ```json
295+ ! {
296+ ! "year": 1805,
297+ ! "value": 0.1E+1
298+ ! }
286299 ! ```
287- !
288300 type,public :: json_value
289301
290302 ! force the constituents to be stored contiguously
@@ -325,25 +337,29 @@ module json_module
325337 ! # Example
326338 !
327339 ! ```fortran
340+ ! program test
341+ ! use json_module
342+ ! implicit none
328343 ! type(json_file) :: json
329344 ! integer :: ival
330345 ! real(real64) :: rval
331346 ! character(len=:),allocatable :: cval
332347 ! logical :: found
348+ ! call json_initialize()
333349 ! call json%load_file(filename='myfile.json')
334350 ! call json%print_file() !print to the console
335351 ! call json%get('var.i',ival,found)
336352 ! call json%get('var.r(3)',rval,found)
337353 ! call json%get('var.c',cval,found)
338354 ! call json%destroy()
355+ ! end program test
339356 ! ```
340357
341358 type,public :: json_file
342359
343360 private
344361
345- ! the JSON structure read from the file:
346- type (json_value),pointer :: p = > null ()
362+ type (json_value),pointer :: p = > null () ! ! the JSON structure read from the file
347363
348364 contains
349365
0 commit comments