Hi,

Norbert made a good suggestion:

> On 09 Mar 2016, at 11:13, Norbert Hartl <norb...@hartl.name> wrote:
> 
> I'm using NeoJSON and was thinking about how to parse JSON arrays. 
> Implementing web APIs you get often an array back instead of an object. 
> NeoJSON does AFAIK not deal too well with the list case. I added something to 
> ease the usage. [...]

And I committed:

===
Name: Neo-JSON-Core-SvenVanCaekenberghe.33
Author: SvenVanCaekenberghe
Time: 16 March 2016, 11:24:47.837176 am
UUID: 34aac279-4fef-4476-9201-95a64efaea6f
Ancestors: Neo-JSON-Core-SvenVanCaekenberghe.32

Added NeoJSONReader>>#nextListAs: as suggested by Norbert Hartl
Added NeoJSONReaderTests>>#testArrayOfPointsUsingNextListAs
===
Name: Neo-JSON-Tests-SvenVanCaekenberghe.33
Author: SvenVanCaekenberghe
Time: 16 March 2016, 11:25:04.185192 am
UUID: 8f4620bc-d5f5-4b3a-aaf0-ee4b8b7a9ccf
Ancestors: Neo-JSON-Tests-SvenVanCaekenberghe.32

Added NeoJSONReader>>#nextListAs: as suggested by Norbert Hartl
Added NeoJSONReaderTests>>#testArrayOfPointsUsingNextListAs
===

So now you can simplify the following relatively common case:

(NeoJSONReader on: '[ { "x" : 1, "y" : 2 }, { "x" : 3, "y" : 4 } ]' readStream)
   mapInstVarsFor: Point;
   for: #ArrayOfPoints customDo: [ :mapping |
     mapping listOfElementSchema: Point ];
   nextAs: #ArrayOfPoints.

with the simpler:

(NeoJSONReader on: '[ { "x" : 1, "y" : 2 }, { "x" : 3, "y" : 4 } ]' readStream)
   mapInstVarsFor: Point;
   nextListAs: Point.

Sven


Reply via email to