How do I add correctly formatted strings to JSON values?

0 favourites
  • 2 posts
From the Asset Store
This collection of music is the beautiful performance of rather small strings ensemble (8 first violins, 6 second violin
  • I am trying to insert additional strings into a JSON file but when I try to insert:

    "{""activity_name"" : ""noname""}"
    

    the resulting JSON looks like..

    {\"activity_name\" : \"noname\"}
    

    I want the end result to be valid JSON..ie

    {"activity_name" : "noname"}
    

    Should I escape the " in some other way for JSON?

    Additionally when I try to insert a complete piece of parsed JSON into the JSON file all " marks are preceded by a \ in the final JSON.

    eg:

    -> JSON_MAIN: Insert JSON_ACTIVITY_MODEL.GetAsBeautifiedString("") into "profile_1.all_activities" at JSON_MAIN.ArraySize("profile_1.all_activities")

    Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In the end it seems I can only use JSON Set to insert data without the formatting. AFAIK.

    This actually works out to be a neater way in the end anyway as I can use it to adds large chunks of data at once.

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