Skip to content

Function proposal - parseJson() #8

@tmccombs

Description

@tmccombs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions