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""}'" String streamContents: [ :out | (NeoJSONWriter on: out) for: Date customDo: [ :mapping | mapping encoder: [ :value | value yyyymmdd ] ]; nextPut: { #date -> Date today } asDictionary ]. "'{""date"":""2016-11-19""}'"
On 19 Nov 2016, at 15:32, Asbath Sama biyalou <asamabiyalou@yahoo.com> wrote:
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) for: Date customDo: [ :mapping | mapping encoder: [ :value | value asDateAndTime printString ] ]; nextPut: data ]
Did you see some errors.
On 19/11/2016 09:52, Sven Van Caekenberghe wrote:
Did you read https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfu... ?
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 Nov 2016, at 08:24, Asbath Sama biyalou via Pharo-users <pharo-users@lists.pharo.org> wrote:
From: Asbath Sama biyalou <asamabiyalou@yahoo.com>
Subject: NeoJSON with Rest Date: 19 November 2016 at 08:24:13 GMT+1 To: Pharo users users <pharo-users@lists.pharo.org>
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.