@@ -63,7 +63,7 @@ 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
66
+ type (json_value),pointer :: root,a,b,c,d,e,e1,e2,escaped_string
67
67
68
68
error_cnt = 0
69
69
call json_initialize()
@@ -111,6 +111,7 @@ subroutine test_7(error_cnt)
111
111
! "int2": 2
112
112
! }
113
113
! ]
114
+ ! "escaped string": "\\\/\b\f\n\r\t"
114
115
! }
115
116
116
117
! create a json structure:
@@ -196,6 +197,22 @@ subroutine test_7(error_cnt)
196
197
error_cnt = error_cnt + 1
197
198
end if
198
199
call json_add(e,e2)
200
+ if (json_failed()) then
201
+ call json_print_error_message(error_unit)
202
+ error_cnt = error_cnt + 1
203
+ end if
204
+ call json_create_object(escaped_string,' escaped string' )
205
+ if (json_failed()) then
206
+ call json_print_error_message(error_unit)
207
+ error_cnt = error_cnt + 1
208
+ end if
209
+ call json_add(escaped_string,' escaped string' ,&
210
+ ' \/' // &
211
+ achar (8 )// &
212
+ achar (12 )// &
213
+ achar (10 )// &
214
+ achar (13 )// &
215
+ achar (9 ))
199
216
if (json_failed()) then
200
217
call json_print_error_message(error_unit)
201
218
error_cnt = error_cnt + 1
@@ -226,6 +243,11 @@ subroutine test_7(error_cnt)
226
243
call json_print_error_message(error_unit)
227
244
error_cnt = error_cnt + 1
228
245
end if
246
+ call json_add(root,escaped_string)
247
+ if (json_failed()) then
248
+ call json_print_error_message(error_unit)
249
+ error_cnt = error_cnt + 1
250
+ end if
229
251
230
252
nullify(a) ! don't need these anymore
231
253
nullify(b)
@@ -234,12 +256,18 @@ subroutine test_7(error_cnt)
234
256
nullify(e)
235
257
nullify(e1)
236
258
nullify(e2)
259
+ nullify(escaped_string)
237
260
238
261
call json_print(root,output_unit) ! print to the console
239
262
if (json_failed()) then
240
263
call json_print_error_message(error_unit)
241
264
error_cnt = error_cnt + 1
242
265
end if
266
+ call json_print(root,error_unit) ! print to stderr
267
+ if (json_failed()) then
268
+ call json_print_error_message(error_unit)
269
+ error_cnt = error_cnt + 1
270
+ end if
243
271
244
272
call json_destroy(root) ! cleanup
245
273
if (json_failed()) then
0 commit comments