Solved

string in .net

Posted on 2015-02-10
5
100 Views
Last Modified: 2015-03-12
I have below string, and I want to extract each information value like

Model No,
ModelName
NetPrice

How can I do that in c#/code behind? Thanks

{
"PackageKey":null,"PackageNo":1,"TotalPackages":1,"Status":"Ok","Data":
"[
{\"ModelNo\":\"A20X\",\"ModelName\":\"20X FUON LENS\",\"NetPrice\":0.0,\"ListPrice\":29.0,\"AMD\":231.0},
{\"ModelNo\":\"AA-FP\",\"ModelName\":\"12 DC POWER SUPPLY\",\"NetPrice\":0.0,\"ListPrice\":10.4,\"AMD\":107.0}
]"
}
0
Comment
Question by:ITsolutionWizard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 81

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 40602156
{\"ModelNo\":\"AA-FP\",\"ModelName\":\"12 DC POWER SUPPLY\",\"NetPrice\":0.0,\"ListPrice\":10.4,\"AMD\":107.0}
Model No     AA-FP
ModelName 12 DC POWER SUPPLY
NetPrice        0.0       ??????? OR IS IT List price 10.40 ?
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40602171
Is this the exact JSON? The reason I ask is that your "Data" property appears to be an array, but you have it quoted, which in JSON land turns it into a string.

Personally, I would create a class that mimics this structure, and then rely on serialization to populate the values. You can use JSON.NET for this task. Its JsonConvert class makes such serialation straight-forward. json2csharp.com is a handy site for turning JSON into a class structure that you can copy/paste into your project.
0
 
LVL 1

Author Comment

by:ITsolutionWizard
ID: 40602217
It is from wcf Json services.
and we do not have the source codes to view.
0
 
LVL 1

Author Comment

by:ITsolutionWizard
ID: 40605969
How to do that copy the string?
0
 
LVL 1

Author Comment

by:ITsolutionWizard
ID: 40609175
I need some instructions how it works. I have no idea.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question