STON UUID in the key

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

STON UUID in the key

Peter Uhnak
Why does this fail?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
STON fromString: (
    STON toStringPretty: (Dictionary with: UUID new -> nil)
)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I would assume that if it can be serialized, then it should be also parsable.

Having scalars for keys is JSON (and JavaScript) limitation because it's stupid,
but if Smalltalk can have any hashable object for key (so any object), then it should be also possible to STON it in/out.

Would this be hard to change?

Peter
Reply | Threaded
Open this post in threaded view
|

Re: STON UUID in the key

Henrik Nergaard

You need to set “allowComplexMapKeys” in StonReader to true for it to handle objects as keys.

 

| reader |

 

reader := STONReader new.

reader allowComplexMapKeys: true.

reader on: (STON toStringPretty: (Object new-> Morph new -> nil)) readStream.

 

reader next.

 

 

Best regards,

Henrik

 

From: Pharo-users [mailto:[hidden email]] On Behalf Of Peter Uhnák
Sent: Saturday, April 2, 2016 10:45 PM
To: Pharo Users List <[hidden email]>
Subject: [Pharo-users] STON UUID in the key

 

Why does this fail?

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

STON fromString: (

    STON toStringPretty: (Dictionary with: UUID new -> nil)

)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

I would assume that if it can be serialized, then it should be also parsable.

 

Having scalars for keys is JSON (and JavaScript) limitation because it's stupid,

but if Smalltalk can have any hashable object for key (so any object), then it should be also possible to STON it in/out.

 

Would this be hard to change?

 

Peter

Reply | Threaded
Open this post in threaded view
|

Re: STON UUID in the key

Peter Uhnak
Perfect!

Thanks

On Sat, Apr 2, 2016 at 11:21 PM, Henrik Nergaard <[hidden email]> wrote:

You need to set “allowComplexMapKeys” in StonReader to true for it to handle objects as keys.

 

| reader |

 

reader := STONReader new.

reader allowComplexMapKeys: true.

reader on: (STON toStringPretty: (Object new-> Morph new -> nil)) readStream.

 

reader next.

 

 

Best regards,

Henrik

 

From: Pharo-users [mailto:[hidden email]] On Behalf Of Peter Uhnák
Sent: Saturday, April 2, 2016 10:45 PM
To: Pharo Users List <[hidden email]>
Subject: [Pharo-users] STON UUID in the key

 

Why does this fail?

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

STON fromString: (

    STON toStringPretty: (Dictionary with: UUID new -> nil)

)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

I would assume that if it can be serialized, then it should be also parsable.

 

Having scalars for keys is JSON (and JavaScript) limitation because it's stupid,

but if Smalltalk can have any hashable object for key (so any object), then it should be also possible to STON it in/out.

 

Would this be hard to change?

 

Peter