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

How can I deserialize a JSON string into an object / array when I dont know its type(class) in advance? #42

Open
hmassareli opened this issue Oct 15, 2023 · 0 comments

Comments

@hmassareli
Copy link

In my case, my frontend will let the user upload a JSON file, wich will then be parsed to an object, or an array (depending on the file that the user uploads) using assembly-script. I don't really know how to do it because most libs require a class / type in advance to specify what the json will be like.

possible file examples:

"[
{name: "Henrique},
]"

"{
car: "mustang",
amount: 1400,
}"

as you can see, the string doesnt match any pattern, and therefore the output of the function will be unknown as well (object with objects inside, array of objects, etc)

Any idea on how to do it?

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

No branches or pull requests

1 participant