1

We are building our website using Dojo javascript only. For some functionalities, we want to use config files to populate some properties and list items during run time. I know how to Deserialize the XML file in C# server side code, but can I do the same thing in Javascript? Is there any examples that I can reference?

Thanks,

Wei

lwconquer
  • 865
  • 1
  • 8
  • 17
  • Do you mean turning a JSON string into a JSON object? If not, what's there to deserialize? It will already be an object. – Marko May 29 '12 at 21:19
  • For example, I make a self-defined XML file to help me populate my PieChart Widget at runtime, and I need to deserialize it in javascript. – lwconquer May 31 '12 at 14:08

2 Answers2

0

You can use javascript's eval() method

ControlAltDel
  • 33,923
  • 10
  • 53
  • 80
0

You might be looking for Dojo.fromJson: http://dojotoolkit.org/reference-guide/1.7/dojo/fromJson.html#dojo-fromjson

If you get th JSON String in JavaScript, you can just use that function to turn it into objects.

Also, eval() is generally discouraged. When is JavaScript's eval() not evil?

Community
  • 1
  • 1
mawcsco
  • 624
  • 6
  • 18