Solved

string in .net

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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