Click here to Skip to main content
12,950,618 members (59,655 online)
Rate this:
Please Sign up or sign in to vote.
See more:
You are implementing an ASP.NET page. Client-side script requires data. Your application includes a class
named Person with a Name property of type string. The code-behind file of the page includes the following
code segment.
public string JsonValue;
List<person> people = GetPeopleList();
JavaScriptSerializer json = new JavaScriptSerializer();

You need to use the JavaScriptSerializer class to serialize only the Name property of each item in the people
Which code segment should you use?
JsonValue = json.Serialize(people.Select(p => p.Name));

var names = from person in people
select person;
JsonValue = "{" + json.Serialize(names) + "}";

JsonValue = json.Serialize(people.SelectMany( p =>Name.AsEnumerable()));

var names = from person in people
select person;
JsonValue = json.Serialize(names);</person>
Posted 9-Jan-13 1:52am
Updated 9-Jan-13 2:16am
Sandeep Mewara 9-Jan-13 8:17am
And what do you think it should be?

Tried yourself?
Member 9725940 9-Jan-13 8:22am
A. i guess

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,984
CHill60 3,460
Maciej Los 3,053
Jochen Arndt 1,975
ppolymorphe 1,820

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100