We help IT Professionals succeed at work.
Get Started

Extracting Key/values in C#

IzzyTwinkly
IzzyTwinkly asked
on
515 Views
Last Modified: 2015-07-07
Hi,

I have the following string:
[
{"Active":true,"Id":"aa-bb-cc-dd","Name":"$PersonNameA","Properties":[{"Key":"Height","Value":"5.8"},
{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"21"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"0001"}]},
{"Active":true,"Id":"11-22-33-44","Name":"$PersonNameB","Properties":[{"Key":"Height","Value":"5.9"},
{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"27"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"0002"}]},
{"Active":true,"Id":"3g-3f-33-77","Name":"$PersonNameC","Properties":[{"Key":"Height","Value":"6.2"},
{"Key":"Locale","Value":"Fr"},{"Key":"Age","Value":"31"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"0003"}]}
]
 
And want to display the following way:
1) if I want to see a specific person's info,
PersonNameA:
Height: 5.8
Locale: en
Age: 21
Sex: Male
PersonID: 0001

2) If I want to see a specific property
Height:
5.8
5.9
6.2

I tried to use dictionary but couldn't make it work.
Any easier way to achieve this?

Thank you guys!
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE