JSwan - JsonDict not JSON Serializable

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:

out = outfile

How is JSwan designed to work with files? The output from Serialize JSON or ReJsonKV are valid JSON strings in the text panels. Is there no component to write that to a file?

Have you set the GhPython input type hint on x to string?

JSwan and the old Python 2 native json module both try to do the same job, one from Python objects, the other from Grasshopper data (irrespectively). JSwan produces valid JSON strings, so all you have to do i write those strings to the file. The issue is x is a JSONDict, not a JSON string. But the description inside the .Net package looks like JSON, do you never know, the following might work:

with open("data.json", "w") as outfile:

To do everything in Python, e.g. parse the DataTree into a dict using the GH native treehelpers module, an opened file object, such as the one you’ve called outfile (not a file path), needs to be passed to json.dump, e.g.:

x = {
    "4": 5,
    "6": 7,
    "json": "obj"
with open("data.json", "w") as outfile:
    json.dump(x, outfile)