#ifndef JSONPATH_H #define JSONPATH_H #include "json.h" #include "nodes/pg_list.h" typedef enum { JP_ROOT, JP_WILDCARD, JP_INDEX_SUBSCRIPT, JP_KEY_SUBSCRIPT, JP_CALL_CHAR } jp_element_type; typedef struct { jp_element_type type; union { long index; struct { char *ptr; size_t length; } key; } data; // If element was preceded by ".." in pattern bool recursive_descent; } jp_element; typedef enum { JP_REF_NODE, JP_REF_CHAR } JPRefType; typedef struct { JPRefType type; union { json_node *node; struct { const char *bytes; size_t length; } chr; } u; } JPRef; typedef List /* jp_element* */ JSONPath; JSONPath *jp_parse(const char *pattern); char *jp_show(JSONPath *jp); List /* JPRef* */ *jp_match(JSONPath *jp, json_node *json); void jp_set(JSONPath *jp, json_node *json, json_node *value); /* Returns the JSON encoding of the given reference. */ char *jpref_encode(JPRef *ref); #endif