HDK
|
Implement simple JSONPath parser. More...
#include <UT_JSONPath.h>
Static Public Member Functions | |
static bool | find (UT_Set< const T * > &matches, const T &src, const char *expr) |
Implement simple JSONPath parser.
This supports a very simple JSONPath syntax:
$
: root object@, this
: current objectpath
: named operator. or []
: child operator (path or index)[,]
: union operator (union of paths or indices)..
: recursive descent*
: wildcardLimitations:
$.book[?(@.cost<7)].title
) Extensions:path
objects can be regex expressionsAs there's no formal syntax for JSONPath, this class was inspired from https://goessner.net/articles/JsonPath/
For example, with the JSON:
Paths would resolve:
The template expects a functor class to provide information about the object, which needs to have:
static inline bool isArray(const T *obj);
static inline bool isMap(const T *obj);
static inline const T *arrayItem(const T *obj, exint idx);
static inline const T *mapItem(const T *obj, const char *name);
static inline iterator arrayBegin(const T &obj);
static inline iterator arrayEnd(const T &obj);
static inline iterator mapBegin(const T &obj);
static inline iterator mapEnd(const T &obj);
Definition at line 90 of file UT_JSONPath.h.
|
inlinestatic |
Definition at line 93 of file UT_JSONPath.h.