[Rules] Add string functions unescape, escape, parse and json - #5600
Open
tonhuisman wants to merge 4 commits into
Open
[Rules] Add string functions unescape, escape, parse and json#5600tonhuisman wants to merge 4 commits into
unescape, escape, parse and json#5600tonhuisman wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inspired by #5597 and some Forum requests here and here, and the long-standing TODO for proper JSON parsing.
Features:
{unescape:<string-to-unescape>}(remove\escape-prefixes from%[]{}()and:).{escape:<string-to-escape>}(insert the\prefix to%[]{}()and:).{parse:<param>:[<separator>]:<string-to-parse-from>}fetch the 1-based parameter from the string, using the separator (default when empty:,).{json:<json-path>:[<asJson>]:<json-string>}retrieve a value from a JSON (escaped) string, using the often usedname.sub.array[n].attrnotation. Returns numeric, string, bool, array(as csv) and object(as name,value csv) values. WhenasJsonis 1, returns a JSON-compatible value (quoted strings, bool: true/false,[]-wrapped arrays and{}-wrapped objects.HTTPResonseParser.cpp, adding support forboolandobjectvalues, and also nesting (recursive). Has a feature-flagFEATURE_JSON__PARSERthat auto-enables if P037 or the HTTP_RESPONSE_PARSER are included.name.attrparser it had.NB: These features are only available in ESP32 builds, as it won't fit in the current set of ESP8266 builds (see our policy here). It can be enabled for a Custom build, using the feature flags
FEATURE_EXTENDED_STRING_FUNCTIONSandFEATURE_JSON_PARSE(enable both to get the JSON-parse feature).TODO: