> On 7 Jun 2018, at 14:42, Norbert Hartl <norb...@hartl.name> wrote:
>
>
>
>> Am 07.06.2018 um 14:16 schrieb Tim Mackinnon <tim@testit.works>:
>>
>> Thanks guys - it seems like I was on the right track.
>>
>> Making my own NeoJsonObject did work, but I will go back and see if I’m
>> really using the js nature of the values and if for this, just an
>> OrderedDictionary might be clearer.
>>
> And safer. The current implementation of NeoJSONObject is not ver good. It
> returns nil on any missing key so you mask a lot of errors in your code which
> I find dangerous.
Haha, it was modelled after a JavaScript object, of course it is worse, but
more convenient in scripting code.
Sure, a plain Dictionary is better.
> Norbert
>
>> As an aside, I was doing some experiments with prismic.io (a headless cms)
>> and the order of your content when rendering it on a page(generically) is
>> obviously important.
>>
>> Tim
>>
>> Sent from my iPhone
>>
>>> On 7 Jun 2018, at 07:46, Sven Van Caekenberghe <s...@stfx.eu> wrote:
>>>
>>>
>>>
>>>> On 7 Jun 2018, at 08:16, Norbert Hartl <norb...@hartl.name> wrote:
>>>>
>>>>
>>>>
>>>>> Am 07.06.2018 um 07:29 schrieb Sven Van Caekenberghe <s...@stfx.eu>:
>>>>>
>>>>> Tim,
>>>>>
>>>>>> On 7 Jun 2018, at 01:37, Tim Mackinnon <tim@testit.works> wrote:
>>>>>>
>>>>>> Hi - I’ve hit some Json where the outputted values (they are field
>>>>>> names) are written out in a specific order - and the author hasn’t
>>>>>> chosen to use an array to represent those fields in a specific order.
>>>>>>
>>>>>> { ‘field1’ : { ….}, ‘field2’: { … } }
>>>>>>
>>>>>> I think this is technically incorrect and should be:
>>>>>>
>>>>>> { [ {‘field1’ : { ….}, ‘field2’: { … } ]}
>>>>>>
>>>>>> Anyway - given what I’ve got, would it be a terrible idea to create my
>>>>>> own version NeoJsonObject and just make it a subclass of
>>>>>> OrderedDictionary?
>>>>>>
>>>>>> I can’t see any issues - but then I might be kidding myself…
>>>>>>
>>>>>> Tim
>>>>>
>>>>> Yea, I think you could try making a NeoJSONOrderedObject as a subclass of
>>>>> OrderedDictionary, modelled after NeoJSONObject. Just remember it is
>>>>> implemented using DNU, which will surprise you at one point.
>>>>>
>>>> Wouldn‘t be setting #mapClass: on the reader to OrderedDictionary not
>>>> enough? Dictionary is the default anyway.
>>>>
>>>> Norbert
>>>
>>> Yes, of course, Norbert, it keeps the order:
>>>
>>> (NeoJSONReader on: '{"BB":1,"CC":2,"AA":3}' readStream) mapClass:
>>> OrderedDictionary; next.
>>>
>>> => an OrderedDictionary('BB'->1 'CC'->2 'AA'->3)
>>>
>>> NeoJSONWriter toString: (OrderedDictionary new at: #BB put: 1; at: #CC put:
>>> 2; at: #AA put: 3; yourself).
>>>
>>> => '{""BB"":1,""CC"":2,""AA"":3}'
>>>
>>> It is not functionally 100% the same as a hypothetical
>>> NeoJSONOrderedObject, but might do.
>>>
>>> Sven
>>
>>
>
>