Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] make a public api for converting Model to json-ast model (JsonValue) #32

Closed
stevelr opened this issue Jun 19, 2021 · 1 comment

Comments

@stevelr
Copy link

stevelr commented Jun 19, 2021

I have a use case where I need the json-ast semantic model in memory as a serde_json::Value. JsonWriter computes this Value internally before serializing it out to a json-text representation.

The work-around I'm using is to use JsonWriter to write the model, then use serde_json to read it back in again to construct the Value. If JsonWriter exposed its internal Value available through an api, the in-memory semantic model would be easier to obtain.

One way to implement this would be to expose a new function in the atelier-json crate: pub fn json_ast_model(model: &Model) -> Value

JsonWriter could use this function internally, to avoid duplicating code, and there wouldn't be any api change to JsonWriter.

@johnstonskj
Copy link
Owner

Working on this now.

  • Using name model_to_json for consistency with other names.
  • Added all the examples from chapter 17 of the spec as tests.
  • Found and fixed a few reader bugs, especially handling traits on members.

johnstonskj added a commit that referenced this issue Jun 25, 2021
…del](#32).

* Added all snippets from section 17 of the specification as test cases.
* Fixed bugs in reader for handling member traits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants