How do I delete a "cell" from a JSON array?

0 favourites
  • 3 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hello!

    Recently, I have migrated my entire project to a JSON data structure and I am having problems figuring out how to remove values from it without knowing the index.

    The array looks like this (when full), but is also dynamic (it can be less of them)

    "Gacha": [29,30,31,32,33,34,35,36,37,38,39,40],

    Could be like this at some point, or even empty.

    "Gacha": [29,30,31,32,37,38],

    What I need is to check if values from 29 to 34 exist and if they do, delete them.

    Same for range from 36 to 40.

    The parameters for JSON to remove point to index, so I'm not sure how to get the index of the values...

    Thank you for your help!

    Tagged:

  • "Gacha" is an array. You need to loop through it in reverse order and remove values one by one.

    + System: On start of layout
    -> JSON: Set path to "Gacha"
    ----+ System: For "n" from JSON.ArraySize(".")-1 to 0
    --------+ System: JSON.Get("." & LoopIndex) is between 29 and 34 
    ---------> JSON: Remove 1 values at "." starting LoopIndex
    
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "Gacha" is an array. You need to loop through it in reverse order and remove values one by one.

    > + System: On start of layout
    -> JSON: Set path to "Gacha"
    ----+ System: For "n" from JSON.ArraySize(".")-1 to 0
    --------+ System: JSON.Get("." & LoopIndex) is between 29 and 34 
    ---------> JSON: Remove 1 values at "." starting LoopIndex
    
    

    It works perfectly thanks!

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