Hmm, I think that something is definitly missing here.

The same code but instead of using #AsString I use DateAndTime and it
works as expected - and that's what I would expect: use for that
property mapping a valueSchema named "AsString".

It seems to work for all classes, when there is no predefined encoding
available in the running system:Integer has a mathod, DateAndTime not.

Is there any reason why is works that way ?

Marten





Am 21.02.2014 12:07, schrieb Sven Van Caekenberghe:
> 
> On 21 Feb 2014, at 09:18, Norbert Hartl <norb...@hartl.name> wrote:
> 
>> Am 21.02.2014 um 07:50 schrieb itli...@schrievkrom.de:
>>
>>> I have a class with an instance attribute "x" and this one contains an
>>> integer value.
>>>
>>> No when exporting this to json I want to write a string instead of this
>>> number to the json string ...
>>>
>>> neoJsonMapping: mapper
>>> mapper for: self do: [ :mapping |
>>>   (mapping mapInstVar: #x to: 'x') valueSchema: #AsString.
>>> ].
>>>
>>> mapper for: #AsString customDo: [ :mapping |
>>>   mapping encoder: [ :anInteger | x asString ].
>>>   mapping decoder: [ :aString | ... ] ].
>>>
>>> But whatever I do ... only numbers are written out ... and yes of course
>>> I could add additional accessors doing the conversion.
>>


-- 
Marten Feldtmann

Reply via email to