Are we missing something obvious? We have used JSwan to serialize our design data, although when it comes time to write it to a file we get tripped up. When we try json.dump(inputData, filePath) we get a note that the dictionary[str,object]({‘BUIDLING NAME’ : ‘Building NE’, … data is not JSON serializable.
which as I type that out I see the fact it is reading each key/value pair in the JSwan serialized tree as a single str and the next key/value pair is the object of the dictionary. This is certainly a problem. We understand that the JSwan components are doing the serialization. Although, as we worked through this we tried to write the data directly into a file and we received this error “file.write() argument must be string or read-only character buffer, not JsonDict”
Are we seeing it being not serializable (because it is already serialized) and not being write-able because it is already a JsonDict? Our next steps are to try creating python dictionaries that can be used in the json.dump() method within python. (StackOverflow (Python Write to JSON)
we will keep plodding ahead, any thoughts, directions to other knowledge bases or help would be greatly appreciated. we imagine others using JSwan have to export / write the data to a file. we are clearly missing something.
images attached showing efforts thus far
Python snippet:
x being the data coming in via tree, y being filepath
(I thought about the need to cycle through each branch of the data tree with a for statement, similar results)
import rhinoscriptsyntax as rs
import json
json_object = json.dump(x, y)
with open("data.json", "w") as outfile:
outfile.write(x)
out = outfile