What is the right way to append data to an array from json?

0 favourites
  • 6 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Hi,

    currently i have an array which loads data from json. Apparently an event is triggerd which loads another json string (with additianal content, same array structure), but instead of replacing the whole content of the array i want to append the content at the "end" so the existing array will be extended.

    the only way i can imagine to do this right now is to load the new content into a second array and then loop to through the second array appending its content to the first on.

    i just would like to ask if there is a better way to do this?

    kind regards

    Patrick

  • If you don't want to code a json parser (/interpreter), this is probably the fastest solution. Just make sure instead of using stuff like push, better resize the array at start of the merge and then just set at - I think this should be more memory-efficient (not sure tho).

    Other idea would be getting a json-expression out of the exisiting array and merge the two json strings correctly together and after that set the array from the single expression, but I doubt thats any faster, so no reason to do that.

  • Thanks mindfaQ

    here is my current attempt, currently not working, there must be something i am missing. the output of the appended data is always 0

    but i will find the solution

  • ah instead of the width ive extended the height

    Solved

  • would be a bit simpler ^^

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • WOW that looks efficient! thank you so much

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