JSON Level Problems

Hello everyone,

I’m currently working on generating a JSON file using the JSWAN plugin in Grasshopper. I’m not very experienced with handling these files, so I could use some assistance.

My goal is to maintain the existing data tree structure in Grasshopper when creating the JSON file. Specifically, I want to preserve the current grid levels and replicate the same data structure for the slabs as I initially had. In my script, I’m creating and reading the JSON file to obtain the results. However, I’m concerned that if I only have the JSON file, I won’t be able to verify whether the data tree was correct from the beginning.

By the way, if I do not flatten the output coming from the slabs at the beginning I am changing the structure of the grids!

Here’s an image for reference:

Could someone please review this? Is it possible to provide the right data structure using other plugins such as @shapediver I’m unsure of the correct approach. Your help is much appreciated!

Thank you in advance!

JSON File.gh (16.6 KB)

In your definition, you are building a JSON object containing all your information but the data structure of the input tree is lost in there. Either you need to add properties in the JSON that store the path information, or you need to define a JSON structure that retains the shape of the input tree.
However, depending on what your application is, it might be as simple as using the Replace Paths component at the end to dispatch your data in the appropriate branches:

1 Like

Thank for the answer @mathieu1 I will check again on the JSON structure I want.

Using the replace component is not an option since the plan is to read a JSON file and work with it, so I will not have the initial data structure anymore

Thank you for the answer :slight_smile:

1 Like