Best Practices for Storing Big Data(JSON) in Attribute Dictionary

Hello everyone, I have a very big JSON data which currently am storing in attribute dictionary on model.
for example -

Sketchup.active_model.set_attribute("my_tools", "objects", big_json_data.inspect)

so is there any better way which to store big JSON data.
My idea - if we can store only key into the attribute dictionary and create a JSON file locally on the system that file have key value , we can fetch key from attribute dictionary and then read JSON file and match that key to get the value from file.
@DanRathbun @tt_su @Aerilius

I would suggest not to split up data that handles about a model from the actual model. Otherwise your users would always need to manually copy a second file over etc when locating their .skp model elsewhere, or when passing it over to a colleague, …

Just keep the data in the model, but perhaps split it up over multiple entries (keys), even in multiple dictionaries if that would make sense, so that you do not need to read and write the whole thing every time you want to look something up or make a change.

1 Like

I’d use big_json_data.to_json instead of inspect. Then use JSON.parse to read it.

How do you read/write to this JSON blob? All at once? Or do you need to do frequent read/write access? If the latter then storing it as a single large blob might incur noticeable lag. (time and profile)

Thanks for your response . currently we are storing all the JSON in model which causes the lag (slowdown the Sketchup) because of huge data , so is there any best way to solve this problem.

It all depends on the kind of data. Does it really needs to be present in the model all the time? Or, is it some configurational data that handles about more than the objects in the model?

So basically we have n number of products and each product have different different components , each components have material information(which we have to apply on it). material info is basically a hash. so can we just store id of this info into attribute dictionary and rest info into local json . or is there any best way to resolve this problem
for example- each component have this material info

    "name":"MERINOLAM - 21091 MR+ - Frosty White",
    "vendorCode":"21091 MR+",

So basically you have some objects in your model as well as a bunch of data about each object. Can’t you store the object data in an attribute dictionary of that object, instead of a single large one on the model? Every Entity can have attribute dictionaries. Class: Sketchup::Entity — SketchUp Ruby API Documentation


And an attribute dictionary is also an Entity, so it can have child attribute dictionaries.