diff --git a/README.md b/README.md new file mode 100644 index 0000000..d4c5469 --- /dev/null +++ b/README.md @@ -0,0 +1,109 @@ +# JSONPath axiomatic semantics + +** WORK IN PROGRESS ** + +## sequences of JSON values + +A JSONPath is modelled as mapping one sequence of JSON values to another sequence of JSON values. +The `<>` notation is used for sequences, to try to distinguish these from JSON arrays. + +Empty sequence: `<>`. + +Concatenation: ` = ^ `. + +So, for example, the sequence `` is equivalent to the concatenation of three single item +sequences ` ^ ^ `. + +## sequence semantics +A selector `s` takes a sequence of values and applies to each one separately. +The results are then concatenated. + +``` +<> s = <> +(x^y)s = (x s)^(y s) +``` + +## JSON object construction + +If `m` and `n` are JSON objects with no keys in common, then `m ∪ n` is the JSON object containing +all the mappings of `m` and `n` (but no others). + +## compound path semantics + +If JSONPath `p` is selector `s` followed by JSONPath `t`, then for all JSON values `v`: +``` +p = (s)t +``` + +## root selector semantics +`$` is effectively a no-op. If `t` is a JSONPath (without a leading `$`), then: +``` +$t = t +``` +Question: do we need to use something like quasi quotes to clarify the above? + +## selectors + +The following sections describe primitive selectors which can be strung together to form a JSONPath. +### dot child +If `o` is a JSON object which does not have key `k`, then: +``` +.k = <> +``` +and: +``` +.k = +``` + +### union +``` +[u, v] = ([u]) ^ ([v]) +``` + +### bracket child +If `o` is a JSON object which does not have key `k` (for certain forms of k...), then: +``` +[k] = <> +``` +and: +``` +[k] = +``` + +### array slice +If `a` is an array, then: +``` +... details! ... +``` + +If `a` is not an array and `sl` is a slice expression, then: +``` +[sl] = <> +``` + +### recursive descent +If `z` is a scalar: +``` +.. = +``` +If `o` is an empty object: +``` +.. = <> +``` + +If `o` is a JSON object which does not have key `k`, then: +If `o` is an object comprised of `k:v` and an object p: +``` +.. = ()^(..)^(..) +``` +Note: since an object can be deconstructed to the form `o ∪ {k:v}` for arbitrary key `k` in +the original object, the ordering of the result is only partially defined. + +If `a` is an empty array: +``` +.. = <> +``` +If `h` is a JSON value and `t` is a JSON array: +``` +(^t).. = ()^(..)^(t..) +``` \ No newline at end of file