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
sudheer89Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

http://james.newtonking.com/projects/json/help/index.html?topic=html/ConvertingJSONandXML.htm

Giannis
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?
0
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

<person>
     <id>1</id>
     <name>Alan</name>
     <role>Admin1</role>
</person>

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.
0
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

aikimarkCommented:
@sudheer89

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?
0
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
0
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?
0
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.