Skip to content
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

use petitparser to recognize jsonDecode output #163

Open
RandalSchwartz opened this issue Dec 27, 2023 · 1 comment
Open

use petitparser to recognize jsonDecode output #163

RandalSchwartz opened this issue Dec 27, 2023 · 1 comment

Comments

@RandalSchwartz
Copy link

I still occasionally think that I can use petitparser to construct a "lexer" and "grammar" for parsing a decodeJson object tree and map it into richer dart objects. The problem is that decodeJson gives me a tree, not a String. Is there a way to use all the wonderful combining and choosing parts of the grammars to essentially "recognize" the shape of a tree, and then map it into Dart objects at each level?

@renggli
Copy link
Member

renggli commented Dec 27, 2023

Earlier versions of PetitParser could parse over arbitrary lists of (nested) objects. There are two main reasons I removed support: (1) there was no demand for it, you are in fact the first one to ever ask for this; and (2) supporting it comes at the cost of added complexity and a loss of performance (in Dart String and List do not have a shared interface).

If you want to play around with this try v1.7.7, the last version that supported this feature. You'll see that through the code there are numerous checks if the parsed input is a String or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants