-
Notifications
You must be signed in to change notification settings - Fork 27
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
2 questions #16
Comments
to query a JsonValue, you can implement a jmespath in haskell 👍 |
A simple 'jsonValueByKey objectJson stringKey' it's enough to me. |
The json might not be a jsonObject, so we need something more involved than that. Nevertheless, at the end of the youtube video, if I remeber correctly, there are examples to query the json. |
Seeing ramda js, and sanctuary, I believe which a function to retrieve data from Json with this definition, it's a good improvement: jsonPath :: JsonValue -> [String] -> Maybe JsonValue
jsonPath (JsonObject []) _ = Nothing
jsonPath (JsonObject (x:xs)) keys@(k:ks) =
if k == fst x
then jsonPath (snd x) ks
else jsonPath (JsonObject xs) keys
jsonPath val [] = Just val
jsonPath _ _ = Nothing Where the array of strings ('[String]') is the a array of keys to the value |
What happening if I use this input? { "a": 1, "a": 2 }
How I can get a value from parsed JSON?
Ex:
jsonParsed = runParser $ jsonValue "{ "config": { "mode": "dev" } }"
jsonGet jsonParsed "config.mode"
The text was updated successfully, but these errors were encountered: