sending an array of objects at a parameter

71 views
Skip to first unread message

Matthew Shirey

unread,
Sep 22, 2008, 5:37:30 PM9/22/08
to jay...@googlegroups.com
I'm having a hell of a time at this point.  Until now, I've been using JayRock for very simple things.  All of the methods I've used to date have all used primitives as parameters.  Now I need to send both a single custom C# object, but also an array of them.  I really need an example or some documentation to see how this is done.  I don't mind writing the serialization/de-serialization if need be, but I also don't see how to do that.  I sure would appreciate a shove in the right direction.

Thank you,

-- Matthew

Atif Aziz

unread,
Sep 23, 2008, 3:48:37 AM9/23/08
to jay...@googlegroups.com

Now I need to send both a single custom C# object, but also an array of them.  I really need an example or some documentation to see how this is done.  I don't mind writing the serialization/de-serialization if need be, but I also don't see how to do that.

 

If you want to be able to export types without writing any import/export code then your type must meet the following conditions:

 

·        The type is public

·        The type is not a primitive type

·        The type has an default constructor (one that takes no arguments)

·        The type has one or more read/write properties

·        The type is an anonymous class (C# 3)

 

Array support is automatically available in Jayrock. If you’re type does not meet the above criteria, then you’ll need to provide an exporter and/or importer for the type. If you need help with understanding those them let me know and I’ll expand further.

 

You also several attributes available to control export of type members:

 

·        JsonExportAttribue – Apply to mark a read-only property as exportable.

·        JsonIgnoreAttribute – Apply to prevent a read/write property from being exported.

·        JsonMemberNameAttribute – Apply to provide an alternate name for an object member (default is “camelCase”).

·        JsonMemberNamingConventionAttribute – Apply to change the default naming convention for a member name.

 

 

Jayrock also comes with several samples and you’ll find some advanced conversion examples in JsonConversionsDemo:

http://svn.berlios.de/wsvn/jayrock/trunk/samples/JsonConversionsDemo/#_trunk_samples_JsonConversionsDemo_

 

Hope this helps so far.

 

- Atif

Matthew Shirey

unread,
Sep 23, 2008, 4:07:15 PM9/23/08
to jay...@googlegroups.com
Thank you for such complete description, this really helps.
 
-- Matthew

Reply all
Reply to author
Forward
0 new messages