How do I set my array to not take [Object object] as it's value?

0 favourites
  • 8 posts
From the Asset Store
It's here!
$4.95 USD
Creepy and nasty horror track. It's terrifying from the beginning till the end. Goosebumps guaranteed
  • The title says it all. Also, here are some pictures to help in solving the problem. Thank you in advance :D

    Tagged:

  • It's hard to tell what data you're really outputting, but note that Construct arrays and dictionaries can only store number and string types. If you're putting a JS object as a value that is not supported, and will probably end up showing as the string [object Object] (which is what you get when a JS object is converted to a string).

  • This is a part of the data that I'm trying to pass...

    {"c2array":true,"size":[46,12,1],"data":[{"ID":"36","avatar":"20","item_id":"1","quantity":"2","icon_position":"0","storage":"1","destroyed":"1","value":"0.04","level_exp":"0","perks":"0","stats":"0","log":"a:4:{i:0;s:48:\"Claimed last: - Thu, 28 Nov 2019 03:25:50 +0000\";i:1;s:48:\"Claimed last: - Thu, 28 Nov 2019 03:26:55 +0000\";i:2;s:48:\"Claimed last: - Thu, 28 Nov 2019 03:29:22 +0000\";i:3;s:60:\"Used for extraction last: - Thu, 28 Nov 2019 03:31:36 +0000\";}"}]}

    I was wondering how can that be like...

    the [object object] be replaced with the values indicated above.

  • Have you tried opening this php directly from the browser address bar? If it outputs "[object Object]" (and not a JSON string) on the screen, then you will know that the problem is in the PHP code.

  • Yes, I did. It's the third picture. The output is in a json_encode format as well.

  • Can you post your C3 project file, or a screenshot of the event list?

    And also this JSON data in text format (not as a picture).

  • Nvm. I already got it to show in the array. I just did some adjustments in both of my construct and php file. Thank you. :D

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Looking at your PHP script and what it was outputting it appears that you were putting objects in the array. Construct array objects are 3D arrays that can only contain strings and numbers, so it can't understand that. Have you considered just using the JSON plugin instead? It's a lot more flexible about the structure of your JSON file.

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