STON toJsonString produces broken JSON

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

STON toJsonString produces broken JSON

Peter Uhnak
Hi,

shouldn't this throw an error instead of producing a broken JSON?

STON toJsonString: ({'a' -> 'b'})
["a":"b"]

(also STON toJsonString: ('a' -> 'b') => "a":"b")

Clearly I forgot to cast it to dictionary, but shouldn't it throw up?

Thanks,
Peter

Reply | Threaded
Open this post in threaded view
|

Re: STON toJsonString produces broken JSON

Sven Van Caekenberghe-2
Peter,

> On 05 Jun 2016, at 13:10, Peter Uhnak <[hidden email]> wrote:
>
> Hi,
>
> shouldn't this throw an error instead of producing a broken JSON?
>
> STON toJsonString: ({'a' -> 'b'})
> ["a":"b"]
>
> (also STON toJsonString: ('a' -> 'b') => "a":"b")
>
> Clearly I forgot to cast it to dictionary, but shouldn't it throw up?
>
> Thanks,
> Peter

Yes, when working in JSON compatibility mode, it would better throw an error.

The reason for this behaviour is because STON knows the concept of an association as a separate, primitive object. That was a cool contribution done later on. In normal use, you don't see this.

I'll have a look.

Sven



Reply | Threaded
Open this post in threaded view
|

Re: STON toJsonString produces broken JSON

Sven Van Caekenberghe-2
I just committed:

===
Name: STON-Core-SvenVanCaekenberghe.76
Author: SvenVanCaekenberghe
Time: 6 June 2016, 10:34:01.602265 am
UUID: 71eeced4-4b1a-4648-90fa-c89efa709ba6
Ancestors: STON-Core-SvenVanCaekenberghe.75

When in JSON mode, STONWriter should also signal an STONWriterError when an Association is seen (thanks Peter Uhnák)

Update #testRestrictedClassesInJSONMode to cover this case
===
Name: STON-Tests-SvenVanCaekenberghe.66
Author: SvenVanCaekenberghe
Time: 6 June 2016, 10:34:19.068183 am
UUID: 9df675c2-98a7-4644-b4d3-2231ba7c7444
Ancestors: STON-Tests-SvenVanCaekenberghe.65

When in JSON mode, STONWriter should also signal an STONWriterError when an Association is seen (thanks Peter Uhnák)

Update #testRestrictedClassesInJSONMode to cover this case
===

Thanks again, Peter, for reporting this.

Sven

> On 05 Jun 2016, at 13:15, Sven Van Caekenberghe <[hidden email]> wrote:
>
> Peter,
>
>> On 05 Jun 2016, at 13:10, Peter Uhnak <[hidden email]> wrote:
>>
>> Hi,
>>
>> shouldn't this throw an error instead of producing a broken JSON?
>>
>> STON toJsonString: ({'a' -> 'b'})
>> ["a":"b"]
>>
>> (also STON toJsonString: ('a' -> 'b') => "a":"b")
>>
>> Clearly I forgot to cast it to dictionary, but shouldn't it throw up?
>>
>> Thanks,
>> Peter
>
> Yes, when working in JSON compatibility mode, it would better throw an error.
>
> The reason for this behaviour is because STON knows the concept of an association as a separate, primitive object. That was a cool contribution done later on. In normal use, you don't see this.
>
> I'll have a look.
>
> Sven
>
>


Reply | Threaded
Open this post in threaded view
|

Re: STON toJsonString produces broken JSON

Peter Uhnak
On Mon, Jun 06, 2016 at 10:36:02AM +0200, Sven Van Caekenberghe wrote:

> I just committed:
>
> ===
> Name: STON-Core-SvenVanCaekenberghe.76
> Author: SvenVanCaekenberghe
> Time: 6 June 2016, 10:34:01.602265 am
> UUID: 71eeced4-4b1a-4648-90fa-c89efa709ba6
> Ancestors: STON-Core-SvenVanCaekenberghe.75
>
> When in JSON mode, STONWriter should also signal an STONWriterError when an Association is seen (thanks Peter Uhnák)
>
> Update #testRestrictedClassesInJSONMode to cover this case
> ===
> Name: STON-Tests-SvenVanCaekenberghe.66
> Author: SvenVanCaekenberghe
> Time: 6 June 2016, 10:34:19.068183 am
> UUID: 9df675c2-98a7-4644-b4d3-2231ba7c7444
> Ancestors: STON-Tests-SvenVanCaekenberghe.65
>
> When in JSON mode, STONWriter should also signal an STONWriterError when an Association is seen (thanks Peter Uhnák)
>
> Update #testRestrictedClassesInJSONMode to cover this case
> ===
>
> Thanks again, Peter, for reporting this.

I'm always happy to report bugs if I don't need to fix them. :)

Peter