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

Replace our own JSON library, lexer and parser with Yojson #340

Closed
sim642 opened this issue Sep 1, 2021 · 1 comment · Fixed by #342
Closed

Replace our own JSON library, lexer and parser with Yojson #340

sim642 opened this issue Sep 1, 2021 · 1 comment · Fixed by #342
Assignees
Labels
cleanup Refactoring, clean-up

Comments

@sim642
Copy link
Member

sim642 commented Sep 1, 2021

We already integrate Yojson, so we might as well use it for everything. Currently the config system uses our own JSON structures and we have our own JSON lexer and parser.

There's also JsonSchema that checks this custom JSON structure, but if we want to keep that, I guess it could still be adapted to just look at a Yojson structure instead.

@sim642 sim642 added the cleanup Refactoring, clean-up label Sep 1, 2021
@sim642
Copy link
Member Author

sim642 commented Sep 2, 2021

What makes this much more difficult is that Yojson uses a nice and pure data type. But our JSON data type is mutable:

(** Json data structure *)
type jvalue =
| String of string
| Number of num
| Object of jvalue ref Object.t ref
| Array of jvalue ref list ref
| True | False
| Null

So when setting options, we just mutate some ref inside it and that's it. To use Yojson, one would have to recursively reconstruct the modified structure around the change.

@sim642 sim642 self-assigned this Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Refactoring, clean-up
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant