esprima-dotnet icon indicating copy to clipboard operation
esprima-dotnet copied to clipboard

Parse from JSON?

Open ejsmith opened this issue 3 years ago • 2 comments

I'm looking to build a GUI builder for conditions and simple statements. It seems like I would want to make the GUI build up an ES tree and persist that tree for when I need to go back and re-populate the visual builder UI. I don't want to create my own tree model from scratch so I'd like to be able to serialize the model to JSON which I can do using ToJsonString, but it doesn't appear that there is a way to parse that JSON back into the ES tree models. Is that correct? Any ideas on how I would go about doing this?

ejsmith avatar May 10 '21 23:05 ejsmith

Currently there's no built-in way to get back the Esprima object model from JSON, so a JsonReader version would be needed next to current writer implementation.

lahma avatar May 11 '21 05:05 lahma

@ejsmith here is a sample converter wich could be used with System.Text.Json, but it's not yet finished. We need to add all the ast node types, make ist error tolerant and so on... https://github.com/sebastienros/esprima-dotnet/pull/207

jogibear9988 avatar Nov 04 '21 22:11 jogibear9988