How do I load json to array

0 favourites
  • 2 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I written a php code where it will echo a json string like this

    [quote:2f689uul]"{""c2array"":true,""size"":[3,1,1],""data"":[[[""user""]],[[100]],[[999]]]}"

    My PHP code looks like this

    <?php header('Access-Control-Allow-Origin: *');
    header('Content-Typer:application/json');
    
    $username ="user";
    $chips ="100";
    $token ="999";
    
    echo "\"{\"\"c2array\"\":true,\"\"size\"\":[3,1,1],\"\"data\"\":[[[\"\"".$username."\"\"]],[[".$chips."]],[[".$token."]]]}\"
    
    ";  
    ?>[/code:2f689uul]
    
    I requested with ajax to my URL 
    and then on complete I set array to load Json string from Ajax.LastData.
    When I check it nothing happen to my array.
    
    Help please
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This is what you would use if you were pasting JSON into the event sheet.

    "{""c2array"":true,""size"":[3,1,1],""data"":[[[""user""]],[[100]],[[999]]]}"[/code:u5dh7vlp]
    
    When loading through AJAX you don't need to escape the quotation marks so it should look like:
    [code:u5dh7vlp]{"c2array":true, "size":[3,1,1], "data":[[["user"]],[[100]],[[999]]]}[/code:u5dh7vlp]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)