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

Function proposal - parseJson() #8

Open
tmccombs opened this issue Jun 22, 2020 · 1 comment · May be fixed by #30
Open

Function proposal - parseJson() #8

tmccombs opened this issue Jun 22, 2020 · 1 comment · May be fixed by #30

Comments

@tmccombs
Copy link

tmccombs commented Jun 22, 2020

Given a string containing embedded json, parse the json, and return the result.

This might be implemented something like:

registerFunction('parseJson', ([json]) => JSON.parse(json), [{types: [TYPE_STRING]}]);

Examples:

jmespath.search("\"true\"", "parseJson(@)")
// OUTPUTS: true

jmespath.search('"{\"a\":1, \"b\":\"c\"}"', "parseJson(@)")
// OUTPUTS {"a":1, "b":"c"}

The pattern of embedding json inside of strings in json is, unfortunately, somewhat common. For example, in AWS APIs.

@springcomp
Copy link
Contributor

JSON Functions unofficial proposal.

tmccombs added a commit to tmccombs/jmespath.jep that referenced this issue May 31, 2023
JEP for adding to_json and from_json functions

Closes: jmespath#8
@tmccombs tmccombs linked a pull request May 31, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants