Re: [json-lib-user] serializing to new <Object>(<parameters>)
Brought to you by:
aalmiray
From: Costa B. <cos...@ya...> - 2008-03-27 22:02:44
|
This is what I suspected. Because there is no JSON*** object to emulate an object constructor call. For now I will just simply extend the json.org api (which was incorporated to this lib) to generate the constructor call. ----- Original Message ---- From: Andres Almiray <aal...@ya...> To: Costa Basil <cos...@ya...>; jso...@li... Sent: Thursday, March 27, 2008 2:21:09 PM Subject: Re: [json-lib-user] serializing to new <Object>(<parameters>) Yes, you can but it may not turn out to be exactly as you would expect. You can register a JsonBeanProcessor or a JsonValueProcessor that takes care of marshalling the property, you'll need to return a valid JSON value [JSON,null,Number,String,Boolean,JSONFunction] so in your case you'll return a String, something like "new Date( <params> )", which means that when the json string is deserialized on the browser the date won't be automatically created. Enabling arbitrary JS code as property value is a big no-no in many circles but I can clearly see the advantages of doing so, specially if you have the proper security measures in place. Perhaps this can be added as a feature. Cheers, Andres ------------------------------------------- http://jroller.com/aalmiray http://www.linkedin.com/in/aalmiray -- What goes up, must come down. Ask any system administrator. There are 10 types of people in the world: Those who understand binary, and those who don't. To understand recursion, we must first understand recursion. ----- Original Message ---- From: Costa Basil <cos...@ya...> To: jso...@li... Sent: Thursday, March 27, 2008 1:30:17 PM Subject: [json-lib-user] serializing to new <Object>(<parameters>) Is it possible, using json-lib, to serialize an object to a javascript new operator call. For instance, to serialize to a Date value, I would serialize it to new Date(<here go the constructor parameters>). Thanks Ask a question on any topic and get answers from real people. Go to Yahoo! Answers. Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. __________________________________________________________________ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now at http://ca.toolbar.yahoo.com. |