• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 101
  • Last Modified:

Json to Xml conversion

Hi, i am tryong to convert json output to xml. can you please explain me how i can do that in c#? and also what namespaces do i have to use to access the functions regarding the serialization and deserialization of the json. please explain it with some example.

thank you
1 Solution
Ioannis ParaskevopoulosCommented:
You may check Json.NET library available in NuGet and then check this link:


sudheer89Author Commented:
i tried that above link but it is saying like jsonconvert was not there in the current context like that. is there any other way we can do that?
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Can you post a sample record in json and the output you desire.  I am not well versed in C# myself but converting from json to xml could be easy or complex depending on the data.  

If you start out with

     "person": {
      "id": "1",
      "name": "Alan",
      "role": "Admin1"

is it ok to end up with


or do you need more detail in your xml?

I think if you can provide sample input and output, experts can help you code the conversion.
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Is this a one-time conversion?

What have you found during your Internet/EE searches on the subject? There are a lot of hits when I did a search.  
Here is the most interesting/promising one:
http://blog.djekldevelopments.co.uk/?p=317 (conversion using Newtonsoft.Json namespace from http://james.newtonking.com/projects/json/help/)

Did anything you've tried come close to a solution?
sudheer89Author Commented:
the one you show me is correct, but when i am trying to convert that code in the c# its giving the namespace errors and other things. so you please post that conversion code for me and the namespaces, references that are added before using these things. and also one more question i am hp UFT tool to automate the services. when i try to convert the data from json to xml it is saying that the data at the root node is invalid. do have any idea what is that error was?

thank you
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
@sudheer89, do you want to open up this question or ask a new one?   I appreciate the points but did if did my answer give you what you needed?
Bob LearnedCommented:
The first link from jyparask was a good one, and the code was clear, so if the NuGet package was installed, and the code was used, the only issue I could see is that your code was missing a using statement in order to reference JsonConvert.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now