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

feat(stdlib): Json value access utils #2150

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alex-snezhko
Copy link
Member

Closes #1877

Copy link
Member

@spotandjake spotandjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation itself mostly looks great to me with a few minor notes.

I personally feel like as we are likely to add other libraries like Toml, Yaml and maybe more the searching would be better provided as a seperate library and we could have a toSearchable or something in the json library that converts the format. The searching semanitcs between bassically every config language is the same and most of the datatypes are the same.

stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
@ospencer
Copy link
Member

I'd love for us to have combinators to search JSON, somewhat similar to what this TOML library does: https://github.com/ocaml-toml/To.ml?tab=readme-ov-file#lenses

Ours wouldn't need to be quite that complex, and I think you'd only need some minor tweaks.

@alex-snezhko
Copy link
Member Author

@ospencer switched over to using lenses

* @since v0.7.0
*/
provide let prop = propertyName =>
{ get: json => match (json) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR but I don't really like how the formatter handles these records here

Copy link
Member

@spotandjake spotandjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks sick.

stdlib/json.gr Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Show resolved Hide resolved
Copy link
Member

@ospencer ospencer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is beautiful! I'm excited to use this. Just a few minor doc changes and this is good to go.

stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
stdlib/json.gr Outdated Show resolved Hide resolved
@alex-snezhko
Copy link
Member Author

@ospencer done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stdlib: add a searchable json api
3 participants