CURL post to Windows web service strips double quotes from entity

I’m trying to post from CURL into an Aloe XWS service with some JSON, but the WebRequest Entity value comes in with all of the double quotes stripped away from the JSON. Once inside of Xojo, this results in a JSONException in turning the values back into a JSONItem.

Here’s my Windows command line CURL call:

Here’s what I’m seeing in the Xojo debugger for the WebRequest Entity which I am unable to turn back into a JSONItem:

I could stuff back in the double quotes into the string, but it gets a bit tricky around the colons in the datetime element and seems cludgy. Am I using CURL inappropriately?

Do you need to put your entire “-d” string in quotes?

I’ve tried putting it in single quotes, and also in a square bracket as if it was a JSON array of JSONItems. The JSON string still arrives stripped of double quotes.

For further detail, I’m viewing the “Entity” value in the debugger in the AloeXWS class named Application, which is a subclass of WebApplication, and looking in the “HandleURL” event handler. I’m not sure if it is CURL that is stripping out the double quotes, Windows, or Xojo itself.

Thanks for your consideration Jim.

The command line may interpret the quotes.
So you may need to put the whole JSON in quotes and then use " for the inner ones.

Well, I couldn’t find an answer. I should probably try posting the JSON string from a Linux machine to the Windows machine to see if it is the Windows CURL client that is removing the double quotes. In the meantime, I wrote a method that stuffs the double quotes back into the JSON string before parsing it to a JSONItem.

[code]Private Function JSONInsertMissingQuotes2(sContent AS String) as String
VAR sRetVal AS String = sContent

IF sRetVal.IndexOf( “”"" ) > 0 THEN
// There’s already double quotes in the string. Don’t stuff them into the JSON based string.

IF sRetVal.LEFT( 1 ) = "{" THEN
  sRetVal = sRetVal.Middle( 1 )

IF sRetVal.Right( 1 ) = "}" THEN
  sRetVal = sRetVal.Left( sRetVal.Length -1 )

VAR arContent() AS String
arContent = sRetVal.Split( "," )

VAR nLocation AS Integer = 0
VAR sKey, sValue AS String = ""
sRetVal = "{"
FOR EACH sValueSet AS String IN arContent
  nLocation = sValueSet.IndexOf( ":" )
  sKey = sValueSet.Left( nLocation )
  sValue = sValueSet.Middle( nLocation+1 )
  sRetVal = sRetVal + """" + sKey + """:""" +  sValue + ""","
sRetVal = sRetVal.Left( sRetVal.Length - 1 ) + "}"



End Function

Christian’s suggestion about escaping the quotes is probably your answer.