-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Filter Key by Size? #1636
Comments
Hi @dmadison, There have been several contradicting requests to extend the filtering feature, but they all focused on arrays (#1316, #1478, #1486, #1598). So that's the first time someone asks to restrict the length of strings. I understand your goal, but I have the following objections:
I'm willing to augment the filtering feature, but we need to find something more versatile. Best regards, |
Thanks for the quick response, Benoit. A few thoughts on your objections:
I'm not sure I understand your objection here. Aren't the JSON keys already filtered by the presence or lack of keys in the filtering document? Perhaps I'm misusing or misunderstanding the word "key" here.
This is a good point. It makes sense to me but I can see it being confusing, especially in the context of array filtering. The other alternatives I can think of (e.g. In place of filtering the other idea I had was to create an additional
Haha fair enough 😛 I understand that this feature is not a good fit for the library at this time; feel free to close this issue if you wish. For context, I'm dealing with an API that can return arbitrary user strings (e.g. user profile descriptions) which vary wildly in length. They also unfortunately sit in the middle of the JSON response so if the document is undersized the more important data won't be deserialized. My current solution is to dramatically oversize the JSON document, although that's predictably not an efficient or robust long-term fix. |
You're right about point 1; I withdraw this objection. I thought about the custom query language like I also thought about adding callable type value for |
Hello again!
The filtering feature is incredibly useful, although at the moment it's currently limited to including / excluding keys. Would it be possible to extend the filtering feature to limit values to a given size?
My suggested API would be the same as the current filtering API, except that instead of setting a key to 'true' to save it you would set the key to the number of characters to parse. Using JsonFilterExample.ino as a demo:
Key values that are larger than the specified amount would be truncated.
The benefit would be that it would be easier to control the size of the JSON document, as unexpectedly large fields would no longer take up additional memory.
The text was updated successfully, but these errors were encountered: