Dictionary inside Dictionary

0 favourites
  • 4 posts
From the Asset Store
94 Inside buildings views - Isometric view - PNG transparent - 2048x2048
  • Hi. I have my set of data which is a dictionary that contains keys and another dictionary(asJSON) as value, and in that dictionary there are keys and once again another dictionary(asJSON).

    Here is a roughly idea of how my data structured.

    {"c2dictionary":true,"data":
    {"dict1Z0":"{\"c2dictionary\":true,\"data\":
    {\"dict1Z1\":"{\"c2dictionary\":true,\"data\":{\"you\":\"happy\"}}"}}"}}[/code:3t70cxog]
    The code might not be accurate but you get the idea. Also the real data has much more keys and dictionary inside.
    I tried for each keys but it did not dig deep enough. (or I don't know how to do it properly)
    Anyone has idea of pulling out the key and value then rearrange it in to a one nice dictionary?
    What I need is rearrange into something like this   
    [code:3t70cxog]{"dict1Z0":"dict1Z1","you","happy"[/code:3t70cxog] 
    Thank you.
  • I don't understand your data structure... If there are many different dictionaries, how do you expect to get only one dictionary in the end?

    Anyway, here is a demo I made, maybe it will help. It first wraps 5 dictionary instances into other dictionaries several times, then restores them.

    https://www.dropbox.com/s/oc4i65d0wqm13 ... .capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi Dop. I knew it is going to be you. haha Thanks for always helping noobie like me.

    If there are many different dictionaries, how do you expect to get only one dictionary in the end?

    Well that's exactly what I need. Maybe rearrange is a poor word choice here. What I want to do is access value of the dictionary from inside out and convert it in to one line with comma splitting each of them. I'm trying to provide you project file. Please wait.

    btw thank you for your example project. It is super useful learning material.

  • Looking from your example, I think my missing piece is temp dictionary. I tried using it and it works. Thanks again dop

    For anyone interested.

    https://www.dropbox.com/s/ucfu4zcpfygvnph/dict.capx?dl=0

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