Click here to Skip to main content
15,902,835 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
var jsonresponse = '{"GetCategoryListResult":[{"ErrorMessage":null,"SR_Category_Desc":"Bidding Process (accuracy)","SR_Category_Id":"1"},{"ErrorMessage":null,"SR_Category_Desc":"Timely Payments applications \/accurate","SR_Category_Id":"2"},{"ErrorMessage":null,"SR_Category_Desc":"Adherence to Price as bid","SR_Category_Id":"3"},{"ErrorMessage":null,"SR_Category_Desc":"Adherence to contract schedule","SR_Category_Id":"4"},{"ErrorMessage":null,"SR_Category_Desc":"Ability to complete work on-time","SR_Category_Id":"5"},{"ErrorMessage":null,"SR_Category_Desc":"Change Order claims","SR_Category_Id":"6"},{"ErrorMessage":null,"SR_Category_Desc":" Customer Service (office staff)","SR_Category_Id":"7"},{"ErrorMessage":null,"SR_Category_Desc":" Customer Service (field staff)","SR_Category_Id":"8"},{"ErrorMessage":null,"SR_Category_Desc":" Quality of Products","SR_Category_Id":"9"},{"ErrorMessage":null,"SR_Category_Desc":" Quality of Workmanship","SR_Category_Id":"10"},{"ErrorMessage":null,"SR_Category_Desc":" Adherence to Safety","SR_Category_Id":"11"},{"ErrorMessage":null,"SR_Category_Desc":" Overall Performance","SR_Category_Id":"12"},{"ErrorMessage":null,"SR_Category_Desc":" Full-time competent Supervision","SR_Category_Id":"13"},{"ErrorMessage":null,"SR_Category_Desc":" Sub of a sub payment issues","SR_Category_Id":"14"},{"ErrorMessage":null,"SR_Category_Desc":" Management Cooperation\/Responsiveness","SR_Category_Id":"15"},{"ErrorMessage":null,"SR_Category_Desc":" Turn-around time on documentation\/paperwork including contracts, insurance, and change orders,etc","SR_Category_Id":"16"},{"ErrorMessage":null,"SR_Category_Desc":" Turn-around time on voicemails\/emails","SR_Category_Id":"17"},{"ErrorMessage":null,"SR_Category_Desc":" Planning\/Scheduling\/Coordination of Labor","SR_Category_Id":"18"},{"ErrorMessage":null,"SR_Category_Desc":" Planning\/Scheduling\/Coordination of Materials","SR_Category_Id":"19"},{"ErrorMessage":null,"SR_Category_Desc":" Strived for improvement in work and accepts change willingly","SR_Category_Id":"20"},{"ErrorMessage":null,"SR_Category_Desc":" Working relationship with other onsite subs","SR_Category_Id":"21"},{"ErrorMessage":null,"SR_Category_Desc":" Leased employees","SR_Category_Id":"22"},{"ErrorMessage":null,"SR_Category_Desc":" Insurance complies with contract and submitted timely","SR_Category_Id":"23"},{"ErrorMessage":null,"SR_Category_Desc":" Accessibility of management\/staff","SR_Category_Id":"24"},{"ErrorMessage":null,"SR_Category_Desc":" Do they do what they say they will do","SR_Category_Id":"25"}]}';

How can get only the following, Thanks in advance

[{"ErrorMessage":null,"SR_Category_Desc":"Bidding Process (accuracy)","SR_Category_Id":"1"},{"ErrorMessage":null,"SR_Category_Desc":"Timely Payments applications \/accurate","SR_Category_Id":"2"},{"ErrorMessage":null,"SR_Category_Desc":"Adherence to Price as bid","SR_Category_Id":"3"},{"ErrorMessage":null,"SR_Category_Desc":"Adherence to contract schedule","SR_Category_Id":"4"},{"ErrorMessage":null,"SR_Category_Desc":"Ability to complete work on-time","SR_Category_Id":"5"},{"ErrorMessage":null,"SR_Category_Desc":"Change Order claims","SR_Category_Id":"6"},{"ErrorMessage":null,"SR_Category_Desc":" Customer Service (office staff)","SR_Category_Id":"7"},{"ErrorMessage":null,"SR_Category_Desc":" Customer Service (field staff)","SR_Category_Id":"8"},{"ErrorMessage":null,"SR_Category_Desc":" Quality of Products","SR_Category_Id":"9"},{"ErrorMessage":null,"SR_Category_Desc":" Quality of Workmanship","SR_Category_Id":"10"},{"ErrorMessage":null,"SR_Category_Desc":" Adherence to Safety","SR_Category_Id":"11"},{"ErrorMessage":null,"SR_Category_Desc":" Overall Performance","SR_Category_Id":"12"},{"ErrorMessage":null,"SR_Category_Desc":" Full-time competent Supervision","SR_Category_Id":"13"},{"ErrorMessage":null,"SR_Category_Desc":" Sub of a sub payment issues","SR_Category_Id":"14"},{"ErrorMessage":null,"SR_Category_Desc":" Management Cooperation\/Responsiveness","SR_Category_Id":"15"},{"ErrorMessage":null,"SR_Category_Desc":" Turn-around time on documentation\/paperwork including contracts, insurance, and change orders,etc","SR_Category_Id":"16"},{"ErrorMessage":null,"SR_Category_Desc":" Turn-around time on voicemails\/emails","SR_Category_Id":"17"},{"ErrorMessage":null,"SR_Category_Desc":" Planning\/Scheduling\/Coordination of Labor","SR_Category_Id":"18"},{"ErrorMessage":null,"SR_Category_Desc":" Planning\/Scheduling\/Coordination of Materials","SR_Category_Id":"19"},{"ErrorMessage":null,"SR_Category_Desc":" Strived for improvement in work and accepts change willingly","SR_Category_Id":"20"},{"ErrorMessage":null,"SR_Category_Desc":" Working relationship with other onsite subs","SR_Category_Id":"21"},{"ErrorMessage":null,"SR_Category_Desc":" Leased employees","SR_Category_Id":"22"},{"ErrorMessage":null,"SR_Category_Desc":" Insurance complies with contract and submitted timely","SR_Category_Id":"23"},{"ErrorMessage":null,"SR_Category_Desc":" Accessibility of management\/staff","SR_Category_Id":"24"},{"ErrorMessage":null,"SR_Category_Desc":" Do they do what they say they will do","SR_Category_Id":"25"}]
Posted
Updated 5-Feb-15 1:19am
v3

Since this JSON has a pattern defined, why don't you use deserialize it? And then inside that array, use the indexers ([0]) to get the first object inside that array?

These are some JavaScript JSON deserializers that you can use, please read this thread.

http://stackoverflow.com/questions/6487167/deserialize-from-json-to-javascript-object[^]

The actual documentation about the parseJSON() method is here on jQuery's website[^].
 
Share this answer
 
Something like this;

JavaScript
var responseObject = JSON.parse(jsonresponse);

var theArrayIWant = responseObject.GetCategoryListResult;
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900