-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
x.json2: add ability to decode arrays #21163
Conversation
33c30d3
to
9956a9d
Compare
Isn't there a more efficient way to do this? It feels too lengthy to me. |
I hope there is one but didn't found one yet. Unfortunately there is mess with accessing the comptime type of the array. Had to integrate a similar approach in toml as last option back then :/. It is now used for arrays and maps there: Lines 59 to 87 in c086bee
If that's whats available atm, I hope there will be better ways soon. |
I think we need to support checking the array in a much more functional way. |
Very good initiative!! But I think this will cause a lot of headaches. In the end, the biggest problem today would be finding a good solution to decode Sumtypes (This will probably have to be done more "manually/handled" by the user, calling some method...). After that, array decodes became much simpler. |
I can't wait to have fun again with the new json2 decode. I hope that within the next few months I will have time to finish this project. |
The change just adds array decoding for the types that the current decoder is handling. This might be better then getting empty arrays. Sumtypes might be in their own scope then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work.
@enghitalo JSON does not have sumtypes. JSON does have arrays. -> For the completion of |
Fixes #21150
Adds the ability to decode arrays, as currently it is an empty block:
v/vlib/x/json2/decoder.v
Lines 251 to 252 in 5da1fcc
The feature is integrated in a simple enough manner that it should create little interference with #21039 . It might even help with a TODO there.