Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET
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
Tejal S1.9K
Edited 9-Jan-13 2:16am
Sandeep Mewara at 9-Jan-13 8:17am
And what do you think it should be?
Tried yourself?
Member 9725940 at 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
0 OriginalGriff 310
1 Sergey Alexandrovich Kryukov 166
2 PhilLenoir 164
3 Richard MacCutchan 160
4 Sharmanuj 146
0 Sergey Alexandrovich Kryukov 6,081
1 OriginalGriff 5,115
2 CPallini 2,473
3 Richard MacCutchan 1,597
4 Abhinav S 1,505

Advertise | Privacy | Mobile
Web02 | 2.8.140814.1 | Last Updated 9 Jan 2013
Copyright © CodeProject, 1999-2014
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