Solved

string in .net

Posted on 2015-02-10
5
90 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 78

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

943 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now