@@ -63,9 +63,12 @@ subroutine test_7(error_cnt)
63
63
64
64
integer ,intent (out ) :: error_cnt
65
65
66
- type (json_value),pointer :: root,a,b,c,d,e,e1,e2,escaped_string
66
+ type (json_value),pointer :: root,a,b,c,d,e,e1,e2,escaped_string,p
67
67
logical :: found
68
+ character (kind= CK,len= 1 ), dimension (:), allocatable :: strvec
69
+ character (kind= CK,len= :), allocatable :: string
68
70
71
+ found= .false.
69
72
error_cnt = 0
70
73
call json_initialize()
71
74
if (json_failed()) then
@@ -141,6 +144,12 @@ subroutine test_7(error_cnt)
141
144
call json_print_error_message(error_unit)
142
145
error_cnt = error_cnt + 1
143
146
end if
147
+ call json_get_child(a,' chars' ,p)
148
+ call json_get(p,strvec)
149
+ if (json_failed()) then
150
+ call json_print_error_message(error_unit)
151
+ error_cnt = error_cnt + 1
152
+ end if
144
153
call json_create_object(c,' c' )
145
154
if (json_failed()) then
146
155
call json_print_error_message(error_unit)
@@ -202,23 +211,6 @@ subroutine test_7(error_cnt)
202
211
call json_print_error_message(error_unit)
203
212
error_cnt = error_cnt + 1
204
213
end if
205
- call json_create_object(escaped_string,' escaped string' )
206
- if (json_failed()) then
207
- call json_print_error_message(error_unit)
208
- error_cnt = error_cnt + 1
209
- end if
210
- call json_add(escaped_string,' escaped string' ,&
211
- ' \/' // &
212
- achar (8 )// &
213
- achar (12 )// &
214
- achar (10 )// &
215
- achar (13 )// &
216
- achar (9 ))
217
- if (json_failed()) then
218
- call json_print_error_message(error_unit)
219
- error_cnt = error_cnt + 1
220
- end if
221
-
222
214
call json_add(root,a)
223
215
if (json_failed()) then
224
216
call json_print_error_message(error_unit)
@@ -244,14 +236,23 @@ subroutine test_7(error_cnt)
244
236
call json_print_error_message(error_unit)
245
237
error_cnt = error_cnt + 1
246
238
end if
247
- call json_add(root,escaped_string)
239
+ call json_add(root,' escaped string' ,&
240
+ ' \/' // &
241
+ achar (8 )// &
242
+ achar (12 )// &
243
+ achar (10 )// &
244
+ achar (13 )// &
245
+ achar (9 ))
248
246
if (json_failed()) then
249
247
call json_print_error_message(error_unit)
250
248
error_cnt = error_cnt + 1
251
249
end if
252
-
253
250
call json_add(root,' wacky string' ,[' trim ' ,' and ' ,' adjust' ,' left' ],&
254
251
trim_str= .true. ,adjustl_str= .true. )
252
+ if (json_failed()) then
253
+ call json_print_error_message(error_unit)
254
+ error_cnt = error_cnt + 1
255
+ end if
255
256
256
257
nullify(a) ! don't need these anymore
257
258
nullify(b)
@@ -269,10 +270,17 @@ subroutine test_7(error_cnt)
269
270
end if
270
271
! look for the 'escaped string' entry
271
272
call json_get(root,' escaped string' ,escaped_string,found)
272
- if (.not. found) then
273
+ if (json_failed() .or. .not. found) then
274
+ call json_print_error_message(error_unit)
275
+ error_cnt = error_cnt + 1
276
+ end if
277
+ call json_get(escaped_string,string)
278
+ if (json_failed()) then
273
279
call json_print_error_message(error_unit)
274
280
error_cnt = error_cnt + 1
275
281
end if
282
+ write (error_unit,' (A)' ) " Fetched unescaped 'escaped string': " // string
283
+
276
284
! remove the escaped string entry
277
285
if (found) call json_remove(escaped_string,destroy= .true. )
278
286
call json_print(root,error_unit) ! print to stderr
0 commit comments