Here is my finished JSON:
{
"message": [
{
"name": "John Doe (3)",
"subject": "asdasd",
"message": "lfkjas;dlfkja;sldfjals;dkfj;alsdkjf;laskdfj
al;sdkfj;alsdkfj
adslfkja;slkfja;sdlkfja;sdlkfj
as;dlkfja;lsdkjfa;lsdkfj",
"date": "3/19/2012 2:20:51 PM",
"senttotal": ""
}
]
}
Here is how it is stored in the database:
lfkjas;dlfkja;sldfjals;dkfj;alsdkjf;laskdfj al;sdkfj;alsdkfj
adslfkja;slkfja;sdlkfja;sdlkfj
as;dlkfja;lsdkjfa;lsdkfj
Here is how I insert the data from their message center into the database:
sql = ""
sql = "SET NOCOUNT ON"
sql = sql & " INSERT INTO message (DistID, subject, message, CreatedDate, StatusID)"
sql = sql & " VALUES (" & distID & ", '" & REPLACE(subject, "'", "''") & "', '" & REPLACE(message, "'", "''") & "', GetDate(), 1)"
sql = sql & " SELECT SCOPE_IDENTITY() as NewID"
As long as they write a message on one line it works just fine. But when they start adding line breaks it seems to mess up the JSON.
The above JSON is the response copied using Firebug and formatted using JSONLint.
How can I fix this since a lot of people will be adding line breaks?
You need to replace any line breaks with
\n