I have two B4J applications
One puts a questionnaire into JSON and that gets posted to the other one which is a webserver.
The other one then extracts the contents from the JSON and displays the questionnaire to visitors.
The questions in the questionnaires are written by users not by me.
The problem I came across yesterday was when someone put an ampersand into the text of a question
Everything seems to work fine on the client side
But on the server side
And as soon as you try to parse it you get the following error
Do I need to escape characters on the client side before sending or is there something else I need to do?
If escaping of characters is required, is there a list somewhere of the ones that need to be escaped.
I saw one such list online but it did not include the ampersand in it.
Thanks for any help.
One puts a questionnaire into JSON and that gets posted to the other one which is a webserver.
The other one then extracts the contents from the JSON and displays the questionnaire to visitors.
The questions in the questionnaires are written by users not by me.
The problem I came across yesterday was when someone put an ampersand into the text of a question
Everything seems to work fine on the client side
B4X:
Log(Text) ' looks OK, text includes ,"questiontext":"What is 2 & 2"}
job2.Initialize("Job2", Me)
job2.PostString(FullUrl & "/questionnaireupload",Text)
But on the server side
B4X:
Dim squestionnaireupload As String = req.GetParameter("questionnaire")
log(squestionnaireupload ) 'terminates in ,"questiontext":"What is 2
And as soon as you try to parse it you get the following error
org.json.JSONException: Unterminated string at character 284 of {"questionnairename etc
Do I need to escape characters on the client side before sending or is there something else I need to do?
If escaping of characters is required, is there a list somewhere of the ones that need to be escaped.
I saw one such list online but it did not include the ampersand in it.
Thanks for any help.