PC Review


Reply
Thread Tools Rate Thread

Convert Class Object to JSON string?

 
 
quantass
Guest
Posts: n/a
 
      15th Jan 2007
Im using C#, ASP.NET v1.1. My class contains intrinsic types,
ArrayList, and XmlDocument types. Some variables have the value NULL.

After usng XmlSerializer and the information on:
http://www.phdcc.com/xml2json.htm I'm having issue fully converitng my
class object to a javascript readable string.

The XmlSerializer appears to ignore all variables containing NULL and
so the final JSON output is incomplete. Also I have a DateTime object
within my class. The converted date is horrible, certainly not even
close to what Javascript can parse. Is there a way to set the datetime
format.

Is there anything i can do to resolve this or a better tool for
converting my class object to JSON string?

 
Reply With Quote
 
 
 
 
Ollie Riches
Guest
Posts: n/a
 
      16th Jan 2007
Are you specifiying the xml serialisation attribute 'IsNullable = true', see

http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlelementattribute(VS.80).aspx

also you specify the date format using the XSD type:

http://msdn.microsoft.com/library/de...eworktypes.asp

and xml convert class:

http://msdn.microsoft.com/library/de...classtopic.asp


HTH

Ollie Riches

"quantass" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Im using C#, ASP.NET v1.1. My class contains intrinsic types,
> ArrayList, and XmlDocument types. Some variables have the value NULL.
>
> After usng XmlSerializer and the information on:
> http://www.phdcc.com/xml2json.htm I'm having issue fully converitng my
> class object to a javascript readable string.
>
> The XmlSerializer appears to ignore all variables containing NULL and
> so the final JSON output is incomplete. Also I have a DateTime object
> within my class. The converted date is horrible, certainly not even
> close to what Javascript can parse. Is there a way to set the datetime
> format.
>
> Is there anything i can do to resolve this or a better tool for
> converting my class object to JSON string?
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Complicate json object? Billy Zhang Microsoft ASP .NET 2 15th Aug 2008 10:05 AM
Connection String object Convert to String Variable Type =?Utf-8?B?TWlrZSBNb29yZQ==?= Microsoft ASP .NET 2 26th Oct 2004 03:43 PM
Cannot convert from object class to object shel Microsoft C# .NET 1 22nd Jul 2004 12:26 AM
How to create an object from a string name of class Nguyen Xuan Hoang Microsoft VB .NET 2 11th Jun 2004 07:07 PM
How to initialize class object from given string? Ladislav Kepl Microsoft C# .NET 2 17th Feb 2004 04:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:41 AM.