@@ -63,7 +63,7 @@ subroutine test_7(error_cnt)
6363
6464 integer ,intent (out ) :: error_cnt
6565
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
6767
6868 error_cnt = 0
6969 call json_initialize()
@@ -111,6 +111,7 @@ subroutine test_7(error_cnt)
111111! "int2": 2
112112! }
113113! ]
114+ ! "escaped string": "\\\/\b\f\n\r\t"
114115! }
115116
116117 ! create a json structure:
@@ -196,6 +197,22 @@ subroutine test_7(error_cnt)
196197 error_cnt = error_cnt + 1
197198 end if
198199 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 ))
199216 if (json_failed()) then
200217 call json_print_error_message(error_unit)
201218 error_cnt = error_cnt + 1
@@ -226,6 +243,11 @@ subroutine test_7(error_cnt)
226243 call json_print_error_message(error_unit)
227244 error_cnt = error_cnt + 1
228245 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
229251
230252 nullify(a) ! don't need these anymore
231253 nullify(b)
@@ -234,12 +256,18 @@ subroutine test_7(error_cnt)
234256 nullify(e)
235257 nullify(e1)
236258 nullify(e2)
259+ nullify(escaped_string)
237260
238261 call json_print(root,output_unit) ! print to the console
239262 if (json_failed()) then
240263 call json_print_error_message(error_unit)
241264 error_cnt = error_cnt + 1
242265 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
243271
244272 call json_destroy(root) ! cleanup
245273 if (json_failed()) then
0 commit comments