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

stdlib: add a searchable json api #1877

Open
spotandjake opened this issue Jul 4, 2023 · 1 comment · May be fixed by #2150
Open

stdlib: add a searchable json api #1877

spotandjake opened this issue Jul 4, 2023 · 1 comment · May be fixed by #2150

Comments

@spotandjake
Copy link
Member

We are keeping the initial json pr small so we can get an mvp, we should come back and make a searchable api later.

Possible Propsal here: #1133 (comment)

A seperate idea i had was we break this into a seperate module with the a fromJson and toJson this could allow for reuse, if we ever add a toml or yaml parser to the stdlib.

@spotandjake
Copy link
Member Author

spotandjake commented Mar 19, 2024

If anyone has a good idea for this api let me know, Something like what i propose below might work well:

module JsonSearch

enum SearchError {
  ExpectedGetProperyOnObject,
  PropertyNotFound
}

getProperty(json: Json, property: string) => Result<Json, SearchError>
getPropeties(json: Json) => Result<string[], SearchError> // this could give an Err(ExpectedGetProperyOnObject)

If this is what the api looks like though it would probably be best to add this as a submodule. would love to hear some alternative ideas to the api I suggested above though, especially as the above doesnt make it easy to get nested props.

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

Successfully merging a pull request may close this issue.

1 participant