[squeak-dev] Transfer of binary data between images

Herbert König herbertkoenig at gmx.net
Sat Oct 21 19:06:53 UTC 2017


Hi,

I used JSON with the addition of carrying the class (JSON being 
Javascript born has no concept of classes) because it requires only very 
little work after loading the JSON package. (And because I've been doing 
some web application where I needed JSON anyway.)

Each class needs on the class side:

constructFromJson: j
     ^ self new constructFromJson: j

and on the instance side:

jsonWriteOn: aStream
     Json renderInstanceVariables:
             (self class allInstVarNames collect: [:ea| ea asSymbol])
         of: self
         on: aStream

and:

constructFromJson: j
     j keysAndValuesDo: [:key :value|
         self instVarNamed: key put: value]

Simple, stupid and good enough for several of my applications.

This should work across dialects if the destination image has the 
required classes in the same shape. The @Classname designator is a 
Smalltalk specific extension to JSON. I think it is not good enough to 
transfer object trees with cyclic dependencies. Other languages with a 
different ideas of how a class is constructed it might need more work.

JSON excerpt:

[@IndividualGenom{"halfNum":77,"fitness":2.364011719201257,"fitnesses":null,"geneValues":[-0.7875619210225705,-1.1191086825115324,2.2987547782235476,-2.1996847933965746,3.3254889274350594,-1.7481778033261461 
......

Cheers,

Herbert

Am 21.10.2017 um 18:33 schrieb Kjell Godo:
> Is JSON the preferred way to transfer data between different
>      Smalltalk platforms?
>      like Dolphin S8 visualWorks GnuSmalltalk Smalltalk/X Amber etc?
> i would like a way for all the different things to talk to each other
>      why should they all be seperate?
>
> I am assuming JSON would be best for going between languages like
>      Smalltalk - Lisp
>      ( it is the easiest to get access to everything has a Package for 
> it ).
>
> Are there any Packages that are designed to link different languages 
> together?
>      like Smalltalk - Racket - CommonLisp - SWIProlog etc?
>      i am assuming that sockets + JSON are the easiest quickest way
>      or DCom or what was that Linux d-Bus is d-Bus also on Windows?easy?
>      is COM also on Linux?does anyone use it?hard to use?
>           Dolphin and VisialWork do COM
>      is anyone doing this sort of thing?who would just know?
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20171021/8399fc4d/attachment.html>


More information about the Squeak-dev mailing list