sbcgua / ajson

Yet another json parser serializer for ABAP
MIT License
49 stars 15 forks source link

Support for JSONPath / JSON Pointer / jq #63

Open mbtools opened 2 years ago

mbtools commented 2 years ago

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

sbcgua commented 2 years ago

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 ?

mbtools commented 2 years ago

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

sbcgua commented 2 years ago

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

mbtools commented 2 years ago

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

sbcgua commented 2 years ago

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 commented 2 years ago

Also Json pointer

larshp commented 2 years ago

also stumbled upon https://jmespath.org

sbcgua commented 2 years ago

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