Solved

string in .net

Posted on 2015-02-10
5
87 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
Comment Utility
{\"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 74

Expert Comment

by:käµfm³d 👽
Comment Utility
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
Comment Utility
It is from wcf Json services.
and we do not have the source codes to view.
0
 

Author Comment

by:ITsolutionWizard
Comment Utility
How to do that copy the string?
0
 

Author Comment

by:ITsolutionWizard
Comment Utility
I need some instructions how it works. I have no idea.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

13 Experts available now in Live!

Get 1:1 Help Now