ajson icon indicating copy to clipboard operation
ajson copied to clipboard

Support for JSONPath / JSON Pointer / jq

Open mbtools opened this issue 4 years ago • 8 comments

JSONPath could be a nice addition (https://restfulapi.net/json-jsonpath/):

image

Def:

  methods jsonpath
    importing
      iv_path type string
    returning
      value(ro_json) type if_asjon.

Example:

  lo_json->jsonpath( '$..attributes' ).

Anyone up for a JS or PHP to ABAP port? https://code.google.com/archive/p/jsonpath/downloads

mbtools avatar Jul 22 '21 17:07 mbtools

Nice idea. Worth checking. Just some of commands will not be support e.g. reference from non root.

The .. is also a bit unclear - what if multiple nodes contain the attrs ? Is it the first one to select ?

sbcgua avatar Jul 23 '21 09:07 sbcgua

.. returns all matching attributes. '$..attributes[0]` would give you the first.

mbtools avatar Jul 23 '21 18:07 mbtools

https://github.com/stedolan/jq/wiki/For-JSONPath-users

sbcgua avatar Jul 25 '21 20:07 sbcgua

Jq would be an option, too. Looks like a package of C with dependencies, though.

mbtools avatar Jul 26 '21 13:07 mbtools

That was just for reference. Collecting some more data about the subject. jq is definitely widespread and popular. Maybe implement it's syntax instead. Just maybe.

sbcgua avatar Jul 27 '21 06:07 sbcgua

Also Json pointer

sbcgua avatar Aug 14 '21 06:08 sbcgua

also stumbled upon https://jmespath.org

larshp avatar Nov 15 '21 08:11 larshp

also JSON Pointer, which seems to be a part of JSON schema: https://datatracker.ietf.org/doc/html/draft-handrews-relative-json-pointer-01

sbcgua avatar Apr 15 '22 20:04 sbcgua