JSON faster than Array ?

0 favourites
  • 4 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I haven't been able to find any topic on this, since most posts about arrays are before the new built-in JSON plugin was born.

    I am making a card game and have serious doubts about the way to arrange the deck. There will be much card sorting, which used to be done with arrays. Yet I have seen that, though not on the manual, there are pop/push, sort and insert/delete actions for the JSON object.

    My question is- since JSON is supposed to be quite fast at accesing for it uses path ID, would it be performance wiser to work straight with a JSON, instead of loading an array?

    However, on the documentation, Ashley says Construct JSON is not actually on native layer Javascript. So I am a bit confused.

    I don't need the data to be sorted in rows&columns anyway.

    Would it be faster to handle a deck of cards by parsing a JSON or loading an array? Do loops and tokenAt behave the same with both? Or the JSON path stuff speeds it further up?

    I mean reading and writing too. Pretty much shuffling and sorting, like I said.

    Maybe Ashley can give me a hint.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I’d just use whatever is simplest and easiest to use for your game. I don’t know what the performance differences may be, but they are likely negligible. With card games most things are done with input or after a timer. These are one off things that even if done slow will have no impact whatsoever with FPS or cpu usage. At least nothing you’d notice.

    If you get pauses you can deal with that later.

  • rojohound

    Ok, no slow down. So, as long as I don't loop through the array/JSON everytick and it is not really big, I won't notice.

    Then I am sticking to JSON as standard. It safes me translating the format and allows the use of same structures for the project files and DB from the server (c2array:true size:blabla data:blabla.... off). Needn't parsing backwards AsJson for uploading either.

    Moreover it feels rather natural having each item's data nested inside it, instead of deploying sorted data by index. Retrieving and inserting without tokenat nor looping. Just string path. Definitely JSON.

    Thanks a lot.

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