Generating JSON file from program #1202
-
Hello everyone! While using the playground provided here, I noticed that there is a dinamically updated json form of the program's AST. I was wondering if there is a way to do this in VS Code with programs written using a DSL I designed. I know a json form of the grammar is generated automatically, but I would like to know if there is a way to do this for programs while they are being written using a custom designed DSL. For clarification, this is what I mean (right side of the image): thank you in advance for the help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@MarianBaba You can use the langium/packages/langium/src/serializer/json-serializer.ts Lines 64 to 78 in 2187f83 |
Beta Was this translation helpful? Give feedback.
-
are you looking for something like |
Beta Was this translation helpful? Give feedback.
@MarianBaba You can use the
JsonSerializer
service to generate such a JSON document. It is available in the language injection container.langium/packages/langium/src/serializer/json-serializer.ts
Lines 64 to 78 in 2187f83