473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Convert Class Object to JSON string?

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?

Jan 15 '07 #1
1 5450
Are you specifiying the xml serialisation attribute 'IsNullable = true', see

http://msdn2.microsoft.com/en-us/lib...te(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" <qu******@gmail.comwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
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?

Jan 16 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
9
by: Raphael Jolivet | last post by:
Hello there, I have a bunch of objects that I store in a text file (to store preferences), after having serialized them with JSON. Let's say I have my object : obj1 = { a : 1
2
by: Kevin Newman | last post by:
Hello, I noticed that the JavaScript library for JSON posted on json.org (http://www.json.org/json.js) is modifying Object.prototype (adding a method - toJSONString). I thought this was...
45
by: bigdadro | last post by:
I've created a new class using prototype.js. After I make the ajax.request all references to this.myClassMethodorVariable are lost. Does the ajax method blow out the object persistance? I'm fairly...
2
by: Venkatesh | last post by:
Hi All, I have one small doubt regarding associative arrays. Request somebody to clarify. Is there a javascript utility function (like split) to convert a string to associative array? My...
2
by: phil.swenson | last post by:
I'm using Prototype.js and would like to convert the contents of an HTML table to JSON. Converting to an array first is fine too. Any thoughts on this? I haven't seen anyone do anything this.......
2
by: bylabylamo | last post by:
i have a problem converting a json string that i get from a servlet into a json object using eval function of java script. any one please help me..........
9
by: Jon Paal [MSMD] | last post by:
using json like ( {"Records": , "RecordCount":"1" } ) and jquery like: $.ajax({ .... success: function(json, status) {
0
by: JonTwend | last post by:
I am working with the Twitter API and finding it great fun and generally easy to use. But I am having trouble getting to the data in the trends/current.json file. I am able to loop through the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.