Extracting Key/values in C#

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!
IzzyTwinklyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

YZlatCommented:
Is it a JSON string?
0
käµfm³d 👽Commented:
Create a class to represent that JSON structure:

e.g.

class Person
{
    public bool Active { get; set; }
    public string Id { get; set; }
    public string Name { get; set; }
    public KeyValuePair<string, string>[] Properties { get; set; }
}

Open in new window


Then you can use a deserializer like JSON.NET to deserialize the string into a class instance:

Person[] people = JsonConvert.DeserializeObject<Person[]>(SampleString());

Open in new window


Then you get Intellisense support on the data:

Screenshot
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
it_saigeDeveloperCommented:
Is this exactly the string of data you are dealing with and in this exact format?

-saige-
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

it_saigeDeveloperCommented:
*No Points*

Proof of Concept from Kaufmeds recommendation:
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;

namespace EE_Q28695326
{
	class Program
	{
		static string data = @"[
{""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""}]}
]";

		static void Main(string[] args)
		{
			Person[] people = JsonConvert.DeserializeObject<Person[]>(data);
			var p1 = (from person in people where person.Name.Equals("$PersonNameA") select person).FirstOrDefault();
			if (p1 != null)
			{
				Console.WriteLine("{0}:", p1.Name);
				foreach (var prop in p1.Properties)
					Console.WriteLine("{0}: {1}", prop.Key, prop.Value);
			}

			Console.WriteLine();

			var heights = (from person in people
						from property in person.Properties
						where property.Key.Equals("Height")
						select property);

			Console.WriteLine("Height:");
			foreach (var height in heights)
				Console.WriteLine(height.Value);

			Console.ReadLine();
		}
	}

	class Person
	{
		public bool Active { get; set; }
		public string Id { get; set; }
		public string Name { get; set; }
		public KeyValuePair<string, string>[] Properties { get; set; }
	}
}

Open in new window

Produces the following output -Capture.JPG-saige-
0
IzzyTwinklyAuthor Commented:
Yes. this is  a Json string.
When I enter URL in my program, it returns that result.
Then my program stored it as a string using ReadLine() method.

Actually, I tried
JObject obj = JObject.Parse(resultString);
but I got "Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1." error.

and yes this is the exact string format I am dealing with.
0
IzzyTwinklyAuthor Commented:
I really appreciate your answer. This is fascinating.
However, you already added extra " around the each key and value string.
It would be very hard if I follow this method since there are more than 10 operations(resources) and so many properties to deal with at the end.
Especially, the result will be different each time. For example, there might be 100 people instead of 3.
0
käµfm³d 👽Commented:
However, you already added extra " around the each key and value string.
If the service you are contacting is returning valid JSON, then these quotes would already be in place. I'm afraid I do not understand what you are implying.

It would be very hard if I follow this method since there are more than 10 operations(resources) and so many properties to deal with at the end.
How so?

For example, there might be 100 people instead of 3.
So what is the concern?
0
IzzyTwinklyAuthor Commented:
I got it. I misunderstood it.

It works now!!!
Thank you very much!!!~~

Thank you 'it_saige' as well!
0
it_saigeDeveloperCommented:
As Kaufmed stated the escape characters would already be in place.  Also regardless of the number of returned objects, the code as presented would parse them all (so long as the returned objects follow the same pattern you provided).

Consider the following:
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;

namespace EE_Q28695326
{
	class Program
	{
		static void Main(string[] args)
		{
			List<Person> testing = new List<Person>();
			for (int i = 0; i < 100; i++)
			{
				testing.Add(new Person() { Active = true, Id = string.Format("aa-bb-cc-dd-{0:00}", i), Name = string.Format("PersonName{0:00}", i), Properties = 
					((i % 5 == 0) ? new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>("Height", (5f * i / 100f).ToString()), new KeyValuePair<string, string>("Locale", "en"), new KeyValuePair<string, string>("Age", (10 + i).ToString()), new KeyValuePair<string, string>("Sex", "Male"), new KeyValuePair<string, string>("PersonID", i.ToString("00000")) }
										: (i % 4 == 0) ? new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>("Locale", "fr"), new KeyValuePair<string, string>("Age", (10 + i).ToString()), new KeyValuePair<string, string>("Sex", "Female"), new KeyValuePair<string, string>("PersonID", i.ToString("00000")) }
										: (i % 3 == 0) ? new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>("Age", (10 + i).ToString()), new KeyValuePair<string, string>("Sex", "Unknown"), new KeyValuePair<string, string>("PersonID", i.ToString("00000")) }
										: (i % 2 == 0) ? new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>("Sex", "Undeclared"), new KeyValuePair<string, string>("PersonID", i.ToString("00000")) }
										: (i % 1 == 0) ? new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>("Sex", "Unknown"), new KeyValuePair<string, string>("PersonID", i.ToString("00000")) }
										: new List<KeyValuePair<string, string>>()).ToArray() });
			}

			string json = JsonConvert.SerializeObject(testing.ToArray());

			Person[] people = JsonConvert.DeserializeObject<Person[]>(json);
			var p1 = (from person in people where person.Name.Equals("PersonName50") select person).FirstOrDefault();
			if (p1 != null)
			{
				Console.WriteLine("{0}:", p1.Name);
				foreach (var prop in p1.Properties)
					Console.WriteLine("{0}: {1}", prop.Key, prop.Value);
			}

			Console.WriteLine();

			var heights = (from person in people
						from property in person.Properties
						where property.Key.Equals("Height")
						select property);

			Console.WriteLine("Height:");
			foreach (var height in heights)
				Console.WriteLine(height.Value);

			Console.ReadLine();
		}
	}

	class Person
	{
		public bool Active { get; set; }
		public string Id { get; set; }
		public string Name { get; set; }
		public KeyValuePair<string, string>[] Properties { get; set; }
	}
}

Open in new window

The JSON object looks like - Small sample of 100 objectsFully serialized:
[{"Active":true,"Id":"aa-bb-cc-dd-00","Name":"PersonName00","Properties":[{"Key":"Height","Value":"0"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"10"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00000"}]},{"Active":true,"Id":"aa-bb-cc-dd-01","Name":"PersonName01","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00001"}]},{"Active":true,"Id":"aa-bb-cc-dd-02","Name":"PersonName02","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00002"}]},{"Active":true,"Id":"aa-bb-cc-dd-03","Name":"PersonName03","Properties":[{"Key":"Age","Value":"13"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00003"}]},{"Active":true,"Id":"aa-bb-cc-dd-04","Name":"PersonName04","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"14"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00004"}]},{"Active":true,"Id":"aa-bb-cc-dd-05","Name":"PersonName05","Properties":[{"Key":"Height","Value":"0.25"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"15"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00005"}]},{"Active":true,"Id":"aa-bb-cc-dd-06","Name":"PersonName06","Properties":[{"Key":"Age","Value":"16"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00006"}]},{"Active":true,"Id":"aa-bb-cc-dd-07","Name":"PersonName07","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00007"}]},{"Active":true,"Id":"aa-bb-cc-dd-08","Name":"PersonName08","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"18"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00008"}]},{"Active":true,"Id":"aa-bb-cc-dd-09","Name":"PersonName09","Properties":[{"Key":"Age","Value":"19"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00009"}]},{"Active":true,"Id":"aa-bb-cc-dd-10","Name":"PersonName10","Properties":[{"Key":"Height","Value":"0.5"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"20"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00010"}]},{"Active":true,"Id":"aa-bb-cc-dd-11","Name":"PersonName11","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00011"}]},{"Active":true,"Id":"aa-bb-cc-dd-12","Name":"PersonName12","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"22"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00012"}]},{"Active":true,"Id":"aa-bb-cc-dd-13","Name":"PersonName13","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00013"}]},{"Active":true,"Id":"aa-bb-cc-dd-14","Name":"PersonName14","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00014"}]},{"Active":true,"Id":"aa-bb-cc-dd-15","Name":"PersonName15","Properties":[{"Key":"Height","Value":"0.75"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"25"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00015"}]},{"Active":true,"Id":"aa-bb-cc-dd-16","Name":"PersonName16","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"26"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00016"}]},{"Active":true,"Id":"aa-bb-cc-dd-17","Name":"PersonName17","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00017"}]},{"Active":true,"Id":"aa-bb-cc-dd-18","Name":"PersonName18","Properties":[{"Key":"Age","Value":"28"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00018"}]},{"Active":true,"Id":"aa-bb-cc-dd-19","Name":"PersonName19","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00019"}]},{"Active":true,"Id":"aa-bb-cc-dd-20","Name":"PersonName20","Properties":[{"Key":"Height","Value":"1"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"30"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00020"}]},{"Active":true,"Id":"aa-bb-cc-dd-21","Name":"PersonName21","Properties":[{"Key":"Age","Value":"31"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00021"}]},{"Active":true,"Id":"aa-bb-cc-dd-22","Name":"PersonName22","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00022"}]},{"Active":true,"Id":"aa-bb-cc-dd-23","Name":"PersonName23","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00023"}]},{"Active":true,"Id":"aa-bb-cc-dd-24","Name":"PersonName24","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"34"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00024"}]},{"Active":true,"Id":"aa-bb-cc-dd-25","Name":"PersonName25","Properties":[{"Key":"Height","Value":"1.25"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"35"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00025"}]},{"Active":true,"Id":"aa-bb-cc-dd-26","Name":"PersonName26","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00026"}]},{"Active":true,"Id":"aa-bb-cc-dd-27","Name":"PersonName27","Properties":[{"Key":"Age","Value":"37"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00027"}]},{"Active":true,"Id":"aa-bb-cc-dd-28","Name":"PersonName28","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"38"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00028"}]},{"Active":true,"Id":"aa-bb-cc-dd-29","Name":"PersonName29","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00029"}]},{"Active":true,"Id":"aa-bb-cc-dd-30","Name":"PersonName30","Properties":[{"Key":"Height","Value":"1.5"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"40"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00030"}]},{"Active":true,"Id":"aa-bb-cc-dd-31","Name":"PersonName31","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00031"}]},{"Active":true,"Id":"aa-bb-cc-dd-32","Name":"PersonName32","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"42"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00032"}]},{"Active":true,"Id":"aa-bb-cc-dd-33","Name":"PersonName33","Properties":[{"Key":"Age","Value":"43"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00033"}]},{"Active":true,"Id":"aa-bb-cc-dd-34","Name":"PersonName34","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00034"}]},{"Active":true,"Id":"aa-bb-cc-dd-35","Name":"PersonName35","Properties":[{"Key":"Height","Value":"1.75"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"45"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00035"}]},{"Active":true,"Id":"aa-bb-cc-dd-36","Name":"PersonName36","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"46"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00036"}]},{"Active":true,"Id":"aa-bb-cc-dd-37","Name":"PersonName37","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00037"}]},{"Active":true,"Id":"aa-bb-cc-dd-38","Name":"PersonName38","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00038"}]},{"Active":true,"Id":"aa-bb-cc-dd-39","Name":"PersonName39","Properties":[{"Key":"Age","Value":"49"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00039"}]},{"Active":true,"Id":"aa-bb-cc-dd-40","Name":"PersonName40","Properties":[{"Key":"Height","Value":"2"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"50"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00040"}]},{"Active":true,"Id":"aa-bb-cc-dd-41","Name":"PersonName41","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00041"}]},{"Active":true,"Id":"aa-bb-cc-dd-42","Name":"PersonName42","Properties":[{"Key":"Age","Value":"52"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00042"}]},{"Active":true,"Id":"aa-bb-cc-dd-43","Name":"PersonName43","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00043"}]},{"Active":true,"Id":"aa-bb-cc-dd-44","Name":"PersonName44","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"54"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00044"}]},{"Active":true,"Id":"aa-bb-cc-dd-45","Name":"PersonName45","Properties":[{"Key":"Height","Value":"2.25"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"55"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00045"}]},{"Active":true,"Id":"aa-bb-cc-dd-46","Name":"PersonName46","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00046"}]},{"Active":true,"Id":"aa-bb-cc-dd-47","Name":"PersonName47","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00047"}]},{"Active":true,"Id":"aa-bb-cc-dd-48","Name":"PersonName48","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"58"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00048"}]},{"Active":true,"Id":"aa-bb-cc-dd-49","Name":"PersonName49","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00049"}]},{"Active":true,"Id":"aa-bb-cc-dd-50","Name":"PersonName50","Properties":[{"Key":"Height","Value":"2.5"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"60"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00050"}]},{"Active":true,"Id":"aa-bb-cc-dd-51","Name":"PersonName51","Properties":[{"Key":"Age","Value":"61"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00051"}]},{"Active":true,"Id":"aa-bb-cc-dd-52","Name":"PersonName52","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"62"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00052"}]},{"Active":true,"Id":"aa-bb-cc-dd-53","Name":"PersonName53","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00053"}]},{"Active":true,"Id":"aa-bb-cc-dd-54","Name":"PersonName54","Properties":[{"Key":"Age","Value":"64"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00054"}]},{"Active":true,"Id":"aa-bb-cc-dd-55","Name":"PersonName55","Properties":[{"Key":"Height","Value":"2.75"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"65"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00055"}]},{"Active":true,"Id":"aa-bb-cc-dd-56","Name":"PersonName56","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"66"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00056"}]},{"Active":true,"Id":"aa-bb-cc-dd-57","Name":"PersonName57","Properties":[{"Key":"Age","Value":"67"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00057"}]},{"Active":true,"Id":"aa-bb-cc-dd-58","Name":"PersonName58","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00058"}]},{"Active":true,"Id":"aa-bb-cc-dd-59","Name":"PersonName59","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00059"}]},{"Active":true,"Id":"aa-bb-cc-dd-60","Name":"PersonName60","Properties":[{"Key":"Height","Value":"3"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"70"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00060"}]},{"Active":true,"Id":"aa-bb-cc-dd-61","Name":"PersonName61","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00061"}]},{"Active":true,"Id":"aa-bb-cc-dd-62","Name":"PersonName62","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00062"}]},{"Active":true,"Id":"aa-bb-cc-dd-63","Name":"PersonName63","Properties":[{"Key":"Age","Value":"73"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00063"}]},{"Active":true,"Id":"aa-bb-cc-dd-64","Name":"PersonName64","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"74"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00064"}]},{"Active":true,"Id":"aa-bb-cc-dd-65","Name":"PersonName65","Properties":[{"Key":"Height","Value":"3.25"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"75"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00065"}]},{"Active":true,"Id":"aa-bb-cc-dd-66","Name":"PersonName66","Properties":[{"Key":"Age","Value":"76"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00066"}]},{"Active":true,"Id":"aa-bb-cc-dd-67","Name":"PersonName67","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00067"}]},{"Active":true,"Id":"aa-bb-cc-dd-68","Name":"PersonName68","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"78"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00068"}]},{"Active":true,"Id":"aa-bb-cc-dd-69","Name":"PersonName69","Properties":[{"Key":"Age","Value":"79"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00069"}]},{"Active":true,"Id":"aa-bb-cc-dd-70","Name":"PersonName70","Properties":[{"Key":"Height","Value":"3.5"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"80"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00070"}]},{"Active":true,"Id":"aa-bb-cc-dd-71","Name":"PersonName71","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00071"}]},{"Active":true,"Id":"aa-bb-cc-dd-72","Name":"PersonName72","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"82"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00072"}]},{"Active":true,"Id":"aa-bb-cc-dd-73","Name":"PersonName73","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00073"}]},{"Active":true,"Id":"aa-bb-cc-dd-74","Name":"PersonName74","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00074"}]},{"Active":true,"Id":"aa-bb-cc-dd-75","Name":"PersonName75","Properties":[{"Key":"Height","Value":"3.75"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"85"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00075"}]},{"Active":true,"Id":"aa-bb-cc-dd-76","Name":"PersonName76","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"86"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00076"}]},{"Active":true,"Id":"aa-bb-cc-dd-77","Name":"PersonName77","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00077"}]},{"Active":true,"Id":"aa-bb-cc-dd-78","Name":"PersonName78","Properties":[{"Key":"Age","Value":"88"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00078"}]},{"Active":true,"Id":"aa-bb-cc-dd-79","Name":"PersonName79","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00079"}]},{"Active":true,"Id":"aa-bb-cc-dd-80","Name":"PersonName80","Properties":[{"Key":"Height","Value":"4"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"90"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00080"}]},{"Active":true,"Id":"aa-bb-cc-dd-81","Name":"PersonName81","Properties":[{"Key":"Age","Value":"91"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00081"}]},{"Active":true,"Id":"aa-bb-cc-dd-82","Name":"PersonName82","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00082"}]},{"Active":true,"Id":"aa-bb-cc-dd-83","Name":"PersonName83","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00083"}]},{"Active":true,"Id":"aa-bb-cc-dd-84","Name":"PersonName84","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"94"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00084"}]},{"Active":true,"Id":"aa-bb-cc-dd-85","Name":"PersonName85","Properties":[{"Key":"Height","Value":"4.25"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"95"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00085"}]},{"Active":true,"Id":"aa-bb-cc-dd-86","Name":"PersonName86","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00086"}]},{"Active":true,"Id":"aa-bb-cc-dd-87","Name":"PersonName87","Properties":[{"Key":"Age","Value":"97"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00087"}]},{"Active":true,"Id":"aa-bb-cc-dd-88","Name":"PersonName88","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"98"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00088"}]},{"Active":true,"Id":"aa-bb-cc-dd-89","Name":"PersonName89","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00089"}]},{"Active":true,"Id":"aa-bb-cc-dd-90","Name":"PersonName90","Properties":[{"Key":"Height","Value":"4.5"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"100"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00090"}]},{"Active":true,"Id":"aa-bb-cc-dd-91","Name":"PersonName91","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00091"}]},{"Active":true,"Id":"aa-bb-cc-dd-92","Name":"PersonName92","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"102"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00092"}]},{"Active":true,"Id":"aa-bb-cc-dd-93","Name":"PersonName93","Properties":[{"Key":"Age","Value":"103"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00093"}]},{"Active":true,"Id":"aa-bb-cc-dd-94","Name":"PersonName94","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00094"}]},{"Active":true,"Id":"aa-bb-cc-dd-95","Name":"PersonName95","Properties":[{"Key":"Height","Value":"4.75"},{"Key":"Locale","Value":"en"},{"Key":"Age","Value":"105"},{"Key":"Sex","Value":"Male"},{"Key":"PersonID","Value":"00095"}]},{"Active":true,"Id":"aa-bb-cc-dd-96","Name":"PersonName96","Properties":[{"Key":"Locale","Value":"fr"},{"Key":"Age","Value":"106"},{"Key":"Sex","Value":"Female"},{"Key":"PersonID","Value":"00096"}]},{"Active":true,"Id":"aa-bb-cc-dd-97","Name":"PersonName97","Properties":[{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00097"}]},{"Active":true,"Id":"aa-bb-cc-dd-98","Name":"PersonName98","Properties":[{"Key":"Sex","Value":"Undeclared"},{"Key":"PersonID","Value":"00098"}]},{"Active":true,"Id":"aa-bb-cc-dd-99","Name":"PersonName99","Properties":[{"Key":"Age","Value":"109"},{"Key":"Sex","Value":"Unknown"},{"Key":"PersonID","Value":"00099"}]}]

Open in new window

And produces this output -Capture.JPG
-saige-
0
IzzyTwinklyAuthor Commented:
Yes saige.

You are absolutely right.
This was my fault. Now the code works beautifully.
I will be more careful from next time.
Thanks again!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.