Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3773

Webresponse and spaces contained in json response fields

$
0
0

if I create a webservice that returns a json item whose fields that cointains spaces,
the json content will be result malformed (iin a random position but always near to a space character ) to the parser that interprets it

you can try with this code in handleurl of webapp session

if Request.Path=“test” then

dim dic as Dictionary
dim jout as new JSONItem
dim dataOggi as datetime =DateTime.Now
dim i as Integer

jout.Compact=false

for i= 0 to 100
dic=new Dictionary
dic.Value(“label1”)=“OK”
dic.Value(“label2”)=“pre space1 space2 space3 space4 " + str(i)+” post space5 "
dic.Value(“date”)= dataOggi
jout.Add(dic)
next i

response.Write(jout.ToString)
response.Status=200
return True

end if

if i parse the returned string in json online parses , the result is

Bad control character in string literal in JSON at line 2 column 0 (line 2 column 255)

Does anyone have solutions to this problem

14 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 3773

Trending Articles