[solved] How do I find out size of a JSON database

0 favourites
  • 5 posts
From the Asset Store
220 Food Sprites in 16x16 pixel size. Perfect for items for a retro style game.
  • Hi,

    Is it possible to find out the size of a JSON database?

    Database

    • 1: Price:50, Time:10
    • 2: Price: 100, Time: 20
    • 3: Price: 150, Time: 30
    • 4: Price: 200, Time: 40

    so I need the variable 4, but how? Anyone an idea, tip, hint?

    Thx

  • Without using the "JSON plugin", you could create a dictionary object and add all the values you want there.

    Then you will be able to retrieve any value just by knowing the name of the value you need.

    Also, if you want to make a JSON string that includes all the dictionary, all you have to do is to text Dictionary.asJSON anywhere you want (for example inside a key in webstorage)

    Take a look: https://www.scirra.com/manual/140/dictionary

  • ok, I don't see which command could help me? I think there is also a little misunderstanding.

    I'll explain what I need:

    I have a text box which shows the actual e.g. research level. When you click the spirit, it goes to the next "level". Of course somewhen there is no next level and then "undefined" appears. This is not nice

    I want to add a compare value in it, which says you can go to the next level until there is no one, which stops adding a additional level.

    so something like that. compare level <= json maximum of this database. I don't want to add manually a global variable, which says this database has 4 Levels. C2 should do this automatically for me

  • hahaha.... easier than thought..

    there is a command database.size(0)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Excellent!

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