Closed JewishLewish closed 2 months ago
Let me think about that one. It isn't part of the spec and I'm not certain how regex would play with encoding.
I don't think regex would play with encoding rather finding the key you are searching for in the Json Ex.
{
"name": {"first": "Tom", "last": "Anderson"},
"age":37,
"children": ["Sara","Alex","Jack"],
"fav.movie": "Deer Hunter",
"friends": [
{"first": "Dale", "last": "Murphy", "age": 44, "nets": ["ig", "fb", "tw"]},
{"first": "Roger", "last": "Craig", "age": 68, "nets": ["fb", "tw"]},
{"first": "Jane", "last": "Murphy", "age": 47, "nets": ["ig", "tw"]}
]
}
"name.last" >> "Anderson"
"age" >> 37
"children" >> ["Sara","Alex","Jack"]
"children.#" >> 3
"children.1" >> "Alex"
"child*.2" >> "Jack"
"c?ildren.0" >> "Sara"
"fav\.movie" >> "Deer Hunter"
"friends.#.first" >> ["Dale","Roger","Jane"]
"friends.1.last" >> "Craig"
(note: I'm using gjson as an example)
It isn't required for json encoding, locating or decoding however regex can come useful when it comes to searching data.
It isn't the encoding of json but the json pointer itself. There aren't many rules but they'd potentially conflict with regex.
No matter how the expressions were represented, it would be novel. For a lib that's supposed to adhere to a spec, that's likely not ideal.
I'm a fan of gjson / sjson (used them both in go before he ported them to rust) but he doesn't have a spec to follow.
I am closing this as I believe it is outside the scope of this crate.
Thank you for the suggestion but the functionality would exceed the specification and add novel behavior.
Suggestion
Do you think there is the potential of adding Regex? I know there is already a crate for Rust Regex: https://docs.rs/regex/latest/regex/