How do I convert this dictionary into Construct 3 format?

  • I used the Wal-Mart API search function to pull a list of items in JSON format that I would like to use in this game I'm making. I know I need to edit the file a little so I can load it using the load dictionary action, however I can't figured out just exactly needs edited. I tried copy and pasting the data in between the {} in {"c2dictionary":true,"data":{}}, but that didn't work, maybe I need to delete the data from the first lines of the file or something. Any help would be greatly appreciated. Don't hesitate to ask questions.

    Here is a download link to the Construct 3 project that has the file I'm trying to convert.

    drive.google.com/file/d/1akKmTsSDbsDRlyF76zuAL5lHq0befPJs/view

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Dictionary in C2/C3 is "one-dimensional", it can only hold a simple list of keys and values.

    If you open your file in Firefox or any other program that can view JSON files, you'll see that it has a complex structure - there are 4 or 5 nested levels. You can't simply import this into a single dictionary, you will get a mess. You will need to develop some sort of a "database" structure with multiple dictionaries/arrays and the way to link records between them. This is not an easy task.

    There are a couple of plugins for C2 that allow to load and parse complex JSON files like this, but I don't know if any of those plugins were ported for C3.

  • Dictionary in C2/C3 is "one-dimensional", it can only hold a simple list of keys and values.

    If you open your file in Firefox or any other program that can view JSON files, you'll see that it has a complex structure - there are 4 or 5 nested levels. You can't simply import this into a single dictionary, you will get a mess. You will need to develop some sort of a "database" structure with multiple dictionaries/arrays and the way to link records between them. This is not an easy task.

    There are a couple of scirra.com/forum/c2-plugins-and-behaviors-list_t65170 plugins for C2 that allow to load and parse complex JSON files like this, but I don't know if any of those plugins were ported for C3.

    I just need the item list from the JSON file. If I manually remove the stuff I don't need, could I turn it into an array or dictionary? I'm trying to make a game similar to the game show "The Price is Right" using the Wal-Mart API to pull product info and put it in a file. Then I'm going to use that file for the game. I'm just trying to avoid have to put the whole file into a string and parsing it to get the info I need, or putting each line of the file into an index of an array and searching the array.

  • If this is just a one time job and you are willing to manually edit the JSON file, it would be easier to make a simple list in plain text rather than keep it in JSON format:

    Item1, price

    Item2, price

    Item3, price

    Then you parse this list using tokencount and tokenat expressions. There are lots of tutorials on how to do it.

    If you need to dynamically load the list of products from the website with the most recent prices, you can parse the JSON file as a text file - searching for tags with the product name and price.

    Here is a demo:

    https://www.dropbox.com/s/cgv055u3bmb4c ... N.c3p?dl=0

  • If this is just a one time job and you are willing to manually edit the JSON file, it would be easier to make a simple list in plain text rather than keep it in JSON format:

    Item1, price

    Item2, price

    Item3, price

    Then you parse this list using tokencount and tokenat expressions. There are lots of tutorials on how to do it.

    If you need to dynamically load the list of products from the website with the most recent prices, you can parse the JSON file as a text file - searching for tags with the product name and price.

    Here is a demo:

    https://www.dropbox.com/s/cgv055u3bmb4c ... N.c3p?dl=0

    My original plan was to edit the JSON using code then have Construct load it as an array or dictionary. The demo you made is almost perfect for what I want to do, thank you very much. I just need to edit the demo to insert the product info into an array instead of a text box. I'm new to Construct and I'm not used to it yet and don't know what it is all capable of and how to do certain things. Again thank you.

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