Thanks for your suggestion. Is it possible in pike to do/use/consume something like 'they' do in dotNET:
[XMLNode name="A"] classA{ [XMLNode name="aVar"] string a; [XMLNode name="cookieCount"] int b; }
On 12-1-2011 16:53, Arne Goedeke wrote:
In any case you will need to know which kinds of objects you want to serialize and come up with some kind of serialization. The Pike JSON module supports encoding arbitrary objects using a callback. But you still need to specify by hand which object variables you want to serialize, etc. Also, when you need to decode the objects again from their json representation you will need to build some code that does this. there is no reasonable way to do this automatically.
You could for instance do something like this
class A { string a, b, c; mapping d, e;
string encode_json() { return JSON.encode(([ "class" : "A", "a" : a, "b" : b, .... ])); }
}
This would then be encoded as a mapping, which you would need to transform back into the object depending on the "class".
arne
On Wed, 12 Jan 2011, Coen Schalkwijk wrote:
Its for storing objects in a database and usage from within multiple different environments. I'll look into JSON. Does pike offer Object-JSON-Object support? If so, could you help me out with a quick example?
On 12-1-2011 15:12, Arne Goedeke wrote:
I dont know if something like this exists. But have you considered using JSON? It works quite well for all standard types, has far less overhead than xml and is easier to parse.
arne
On Wed, 12 Jan 2011, Coen Schalkwijk wrote:
Yes, for example (a very naive one); from a pike string "hello
world" to > <string>hello world</string>
Greetings Coen On 12-1-2011 14:03, Arne Goedeke wrote: What do you mean by that? You want to encode arbitrary pike
objects > > in
XML?
> arne > On Wed, 12 Jan 2011, Coen Schalkwijk wrote: > > > I'm looking for code to translate objects to XML and
back with > > > absolutely NO pike specific encoding of any kind. Is this already > > > available or do I have to make this myself?
> > -- > Met vriendelijke groet / With kind regards / mit
besten > > Gr??en,
> > > > Coen Schalkwijk Software Engineer > coen.schalkwijk@rtl.nl mailto:coen.schalkwijk@rtl.nl > coen@rtlinteractief.nl mailto:coen@rtlinteractief.nl > +31 (0)35 671 8915 > > > >