How do I read json data from ajax having back slashes

Get help using Construct 2

Post » Sat Mar 28, 2015 8:41 pm

I'm working on an application where i'm running the back end with python. I'm returning a json data to my construct 2 app, on the python layer the json format is fine however when the ajax object gets the returned object, there are some strange back slashes in it. how do i work around it? I'm also using a json plugin in construct, and even when i load the data into an object from the plugin the back slashes are still there.
An example of what i have is
"{\"Score\":{\"Shear Modulus\":6,\"Youngs Modulus\":4,\"Compressive Strength\":2,\"Bulk Modulus\":0,\"Tensile Strength\":0},\"Unit\":{\"Shear Modulus\":\"GPa\",\"Youngs Modulus\":\"GPa\",\"Compressive Strength\":\"MPa\",\"Bulk Modulus\":\"GPa\",\"Tensile Strength\":\"MPa\"}}"
Posts: 138
Reputation: 2,003

Post » Sun Mar 29, 2015 1:02 am

I had the same problem when I was trying to save data in a server, if I remember, the problem was the method GET...

your JSON file in your server is without the slashes?
Posts: 298
Reputation: 2,972

Post » Thu Apr 02, 2015 8:03 pm

If I have to guess, you are using GSON to export that data. Use something like:

gson.toJson(object).replaceAll("\\\"","\"") on the server side that should fix your slash issue.

If you don't have access to the server side, you can use a custom JavaScript function in Construct to do almost the exact same thing too.
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
Posts: 1,419
Reputation: 4,867

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests