This works for me:
String streamContents: [ :out |
(NeoJSONWriter on: out)
for: Date customDo: [ :mapping | mapping encoder: [ :value | value
asDateAndTime printString ] ];
nextPut: { #date -> Date today } asDictionary ].
"'{""date"":""2016-11-19T00:00:00+01:00""}'"
--- Begin Message ---
Thank you Sven. I check those example. very helpfull.
But I use this method toJson to convert the stream to json and I get :
PrimitiveFailed: primitive #basicNew: in ByteString class failed
toJson
^ String streamContents: [ :stream |
(NeoJSONWriter on: stream)
This works for me:
Say you have a class called MyObject and you want a JSON representation of
it.
On the *class *side of MyObject add this method:
neoJsonMapping: mapper
"For inheritance mapping to work, the schema/classname must be self,
but the instance variables have to be enu
Did you read
https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/NeoJSON/NeoJSON.html
?
Did you check out the unit tests ? Some of them serve as examples. Checkout
NeoJSONTestObject1 2 3 and the tests #testObject1 2 3 for example.
> On 19 No
--- Begin Message ---
I really want to know how to map my objects using NeoJSON.
I don't have any idea.
thanks.
On 19/11/2016 08:24, Asbath Sama biyalou wrote:
> Hello.
>
> I want an example of implementation of neojson on a pharo object.
>
> I am trying to implement neoJsonOn: method on a phar
--- Begin Message ---
Hello.
I want an example of implementation of neojson on a pharo object.
I am trying to implement neoJsonOn: method on a pharo object but when I
test I get a Character mapping not found
in NeoJSONWriter.
Thanks.
--- End Message ---