Solved

string in .net

Posted on 2015-02-10
5
94 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
  • 3
5 Comments
 
LVL 80

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
 

Author Comment

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

Author Comment

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

Author Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

789 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