JSON import of large catalogue

What is the best strategy for importing JSON files containing component attributes (dimensions, location of drilling holes, material etc).

Is it better to:

  1. Import one ‘large’ JSON file (it is not huge, about 40kb), filter it inside my definition to just the components I am interested in, and throw away the rest?

  2. Have several smaller JSON files, maybe one of each type of attribute? This would mean I would need to do multiple imports and have more logic around deciding what I need to import.

  3. Something else?

At the moment I am doing option 1. My model is slow, and I think this import is the main driver of the refresh speed. It looks like the external file is being polled every time the configuration changes.

Is there a way to stop it polling after the initial import? I cannot use the toggle + stream filter technique to turn off the ShapeDiverTextInput component after importing the JSON - because then my definition is flooded with nulls as the input data is cut off.

Is there a better way?

Many thanks

[If it helps to look at the model, it is the only one in the anysizeflatpack account]

That depends on the size of the JSON file. If you can send the JSON with the ShapeDiverTextInput it means the JSON is pretty small as the component has 10k characters limit. For anything larger use the ShapeDiverTextFileInput component.

The option 2 is better in terms of caching. The parameters are distributed in different inputs and get cached separately. This way the model is computed in different sections as opposed to one large single input, then everything has to be recomputed over again even with small changes. More on use of JSON
files is covered in this part of our webinar.

Having said that, importing JSON should be pretty fast and the reason your model performs poorly might be somewhere else. Check these blog posts and video tutorials for various optimisation techniques.

Thanks for this Pavol, I will take a look at option 2 and see if I can split the files along the same lines as the input paramaters.