How do I read json data from ajax having back slashes

0 favourites
  • 3 posts
  • 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\"}}"

  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)