dude icon indicating copy to clipboard operation
dude copied to clipboard

Selector for JSON contents

Open roniemartinez opened this issue 2 years ago • 0 comments

There are existing ways to extract data from JSON without traversing the contents one by one.

Options

Proposed style

@select(jsonpath="$.store.book[0].title")
def extract_title(title):
    return {"title": title}


@select(jmespath="locations[?state == 'WA'].name | sort(@)")
def extract_washington_cities(cities):
    return {"cities": cities}

Notes

  • Only applies if content type is application/json

roniemartinez avatar Mar 18 '22 23:03 roniemartinez