Add test for JSON deserialization of a list into PointList object, ve…#83
Add test for JSON deserialization of a list into PointList object, ve…#83shanginn wants to merge 2 commits intoCrell:masterfrom
Conversation
…rifying instance type and item count.
|
Unfortunately, this could be quite tricky. Serde is very much built around serializing to/from objects, not arbitrary arrays (or arrays of objects). I'm not sure off hand how we could do that. My best guess would be to not do so, but wrap it in another layer that first json_decode()s the value, then loops and calls Serde deserialize on each element of that, as an array. That wouldn't work for streaming, of course, but we don't support streaming deserialization anyway yet. |
|
Symfony serializer supports it if you pass the type as You can see it implemented in |
|
Fun fact! This turned out to be the same issue as #82, where someone suggested an almost-solution. I was able to carry it the rest of the way. It still doesn't deserialize to a PHP array, but to an object that wraps an array. But it should work for a JSON array if you're careful with it. Calling this issue closed as a duplicate of that one. |
This is a test to demonstrate desired behaviour of list deserialization. Such JSON array lists are common in the REST world and it's unclear how to deserialize them.
The only way to do it now it to json_decode the response, then iterate over it, json_encode each element and deserialize them individually. sure there is a better way?