Re: [Pharo-users] STON shouldn't care about shared references in JSON mode

2018-03-27 Thread Peter Uhnák
> > The class comment clearly states: > The docs also say "When using JSON mode the reference policy should be set to #error or #ignore for full JSON compatibility." But demonstrably setting it to #error does not give me full JSON compatibility. If I feed it valid input, then I expect valid

Re: [Pharo-users] STON shouldn't care about shared references in JSON mode

2018-03-27 Thread Herbert Vojčík
Sven Van Caekenberghe wrote: The JSON spec does (of course) not deal with cycles nor structure sharing, STON does (by design). That surprises me. I thought cycles are explicitly prohibited in JSON. The class comment clearly states: ... - referencePolicy<#normal|#ignore|#error> default

Re: [Pharo-users] STON shouldn't care about shared references in JSON mode

2018-03-27 Thread Sven Van Caekenberghe
The JSON spec does (of course) not deal with cycles nor structure sharing, STON does (by design). The class comment clearly states: ... - referencePolicy <#normal|#ignore|#error> default is #normal if #normal, track and count object references and use references to implement sharing

Re: [Pharo-users] STON shouldn't care about shared references in JSON mode

2018-03-27 Thread Peter Uhnák
Ah sorry, I'm blind. Yes, ideally it should throw up an error in case of recursive. And I see that NeoJSON runs into infinite cycle, so I guess this should be addressed there too. On Tue, Mar 27, 2018 at 6:41 PM, Herbert Vojčík wrote: > > > Peter Uhnák wrote: > >> Hi Sven,

Re: [Pharo-users] STON shouldn't care about shared references in JSON mode

2018-03-27 Thread Herbert Vojčík
Peter Uhnák wrote: Hi Sven, shouldn't it be set to #ignore by default for JSON then? Or is there a use case where it makes sense to have something else for JSON? To keep STON practices / assumptions while using JSON to hold the data where STON is not supported yet, maybe? IIRC STON is

Re: [Pharo-users] STON shouldn't care about shared references in JSON mode

2018-03-27 Thread Peter Uhnák
Hi Sven, shouldn't it be set to #ignore by default for JSON then? Or is there a use case where it makes sense to have something else for JSON? Herbert: I am not talking about (infinitely) recursive references, but referencing the same object, e.g. Peter On Tue, Mar 27, 2018 at 6:08 PM,

Re: [Pharo-users] STON shouldn't care about shared references in JSON mode

2018-03-27 Thread Herbert Vojčík
Sven Van Caekenberghe wrote: Hi Peter, Both cases will pass using this expression: String streamContents: [ :out | STON jsonWriter referencePolicy: #ignore; on: out; nextPut: d ]. The problem is what to do with cycles. Be faithful to

Re: [Pharo-users] STON shouldn't care about shared references in JSON mode

2018-03-27 Thread Sven Van Caekenberghe
Hi Peter, Both cases will pass using this expression: String streamContents: [ :out | STON jsonWriter referencePolicy: #ignore; on: out; nextPut: d ]. The problem is what to do with cycles. Sven > On 27 Mar 2018, at 17:43, Peter

[Pharo-users] STON shouldn't care about shared references in JSON mode

2018-03-27 Thread Peter Uhnák
Hi, I don't think this should throw an error when I am producing JSON. ``` d := { 'a' -> #(). 'b' -> #(). } asDictionary. STON toJsonString: d. ``` dtto this ``` a := {'hm'}. d := { 'a' -> a. 'b' -> a. } asDictionary. STON toJsonString: d. ``` Maybe I should forgo using STON>>toJson* out