I don't really understand why you want to keep the original JSON. It is a bit 
like you don't trust the parsing and/or mapping. Now, the mapping I understand 
(somewhat).

So I would parse once without mapping, which would give you pure Arrays and 
Dictionaries that you are guaranteed can be used to reproduce the full original 
input. Pick the second level in that structure and use it.

> On 12 Mar 2015, at 21:47, Mariano Martinez Peck <marianop...@gmail.com> wrote:
> 
> 
> 
> On Thu, Mar 12, 2015 at 5:32 PM, Sven Van Caekenberghe <s...@stfx.eu> wrote:
> Mariano,
> 
> I assume you what this while reading JSON. That won't be possible. NeoJSON is 
> designed as an efficient stream parser, working as it goes. So it never knows 
> the whole JSON expression.
> 
> Uhhhh I imagined that :(  
>  
> 
> I would do it manually, but that can only be done at the top level.
> 
> Well...my list of TestObject is not at the root, but second level.....
> But in any case... how would you do that? 
> 
> Thanks!
>  
> 
> Sven
> 
> > On 12 Mar 2015, at 21:22, Mariano Martinez Peck <marianop...@gmail.com> 
> > wrote:
> >
> >
> >
> > On Thu, Mar 12, 2015 at 5:16 PM, Esteban A. Maringolo 
> > <emaring...@gmail.com> wrote:
> > Assuming you store the original JSON string as a String object in an
> > instance variable named "json" you could map it as any other string.
> >
> >
> > But how do I get the JSON string associated to the TestObject instance?  In 
> > other words...
> >
> > mapper for: TestObject do: [ :mapping |
> >
> > "HERE how do I get the JSON string of TestObject in order to map it to 
> > 'jsonOriginalString'  ?  "
> >
> > ]
> >
> >
> > Or are you planning to store it as JSON object itself?
> >
> > no, a string is OK.
> >
> > Thanks in advance,
> >
> >
> >
> > Esteban A. Maringolo
> >
> >
> > 2015-03-12 16:50 GMT-03:00 Mariano Martinez Peck <marianop...@gmail.com>:
> > > Hi,
> > >
> > > In this link:
> > > https://github.com/svenvc/docs/blob/master/neo/neo-json-paper.md
> > >
> > > I see an example of a custom mapping like this one:
> > >
> > > mapper for: TestObject do: [ :mapping |
> > >     mapping mapInstVars: #(id name).
> > >     (mapping mapInstVar: #timestamp to: 'created-at') valueSchema:
> > > DateAndTime.
> > >     (mapping mapInstVar: #points) valueSchema: #ArrayOfPoints.
> > >     (mapping mapInstVar: #bytes) valueSchema: ByteArray ].
> > >
> > >
> > > I need something similar, but I need to store the original JSON string 
> > > that
> > > was used to build a particular TestObject instance, in an instance 
> > > variable
> > > of TestObject too. In other words, I need an instVar "originalResponse" in
> > > TestObject that would be set with the original JSON string.
> > >
> > > Any ideas how can I implement this?
> > >
> > > Thanks in advance,
> > >
> > > --
> > > Mariano
> > > http://marianopeck.wordpress.com
> >
> >
> >
> >
> > --
> > Mariano
> > http://marianopeck.wordpress.com
> 
> 
> 
> 
> 
> -- 
> Mariano
> http://marianopeck.wordpress.com


Reply via email to