Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
string json="[
{
"ParentId":"a9764da3147845c184bd272cef6a5937",
"Path":"/LMS/Cabinet/bdc2cd8e1da3451c84e332d1aa74f605",
"CreatedBY":"admin",
"IsActive":"Y",
"CabinetName":"LMS",
"FolderTag":"IT mobile computing,Comm Skills",
"Name":"JAVA",
"UpdatedBY":"",
"Type":"Folder",
"IsDelete":"N",
"UpdatedON":"",
"Id":"bdc2cd8e1da3451c84e332d1aa74f605",
"CreatedON":"2015_09_08-11:19:50",
"TemplateId":"dd42c8a71a954c1d948ef35492ee1242"
},
{
"ParentId":"a9764da3147845c184bd272cef6a5937",
"Path":"/LMS/Cabinet/3aae020c256f4dc1ab705af67bede2c7",
"CreatedBY":"admin",
"IsActive":"Y",
"CabinetName":"LMS",
"FolderTag":"IT mobile computing,Comm Skills",
"Name":"Spring",
"UpdatedBY":"",
"Type":"Folder",
"IsDelete":"N",
"UpdatedON":"",
"Id":"3aae020c256f4dc1ab705af67bede2c7",
"CreatedON":"2015_09_04-16:58:05",
"TemplateId":"dd42c8a71a954c1d948ef35492ee1242"
},
{
"ParentId":"a9764da3147845c184bd272cef6a5937",
"Path":"/LMS/Cabinet/c139b33a22a94a25bf624b94450aee3e",
"CreatedBY":"admin",
"IsActive":"Y",
"CabinetName":"LMS",
"FolderTag":"Social Skills",
"Name":"SQL",
"UpdatedBY":"",
"Type":"Folder",
"IsDelete":"N",
"UpdatedON":"",
"Id":"c139b33a22a94a25bf624b94450aee3e",
"CreatedON":"2015_09_04-16:54:44",
"TemplateId":"dd42c8a71a954c1d948ef35492ee1242"
}
] "

this is my json string and i want to only "Name" field with comma separated into another variable...

example: string res={"JAVA","SPRING","SQL",...}

like that plz give me solution
Posted
Comments
Amit Jadli 9-Sep-15 7:03am    
dynamic iJson = JsonConvert.DeserializeObject(json);
List<string> res = new List<string>();
foreach (var item in iJson)
{
res.add(item.Name);
}

By this you can get all names in list string.
Thanks7872 9-Sep-15 8:07am    
What have you tried till now?
Member 11942465 9-Sep-15 8:36am    
will u plz send me code
Member 11942465 9-Sep-15 8:42am    
dynamic jsonObj = JsonConvert.DeserializeObject(json);


List<string> res = new List<string>();
foreach (var item in jsonObj)
{
res.Add(item.Name);
}
Member 11942465 9-Sep-15 8:40am    
this is my code

dynamic jsonObj = JsonConvert.DeserializeObject(json);


List<string> res = new List<string>();
foreach (var item in jsonObj)
{
res.Add(item.Name);
}

1 solution

var objdata = $.parseJSON(json);

In objdata you will get all the values in which using for loop, get the values in the index 6, which is name
 
Share this answer
 
Comments
Member 11942465 9-Sep-15 8:36am    
will u plz sen me code
Thanks7872 9-Sep-15 8:43am    
No one will. Try it and come back when you have specific question.
Member 11942465 9-Sep-15 8:50am    
i want only name field value like this {"JAVA","SPRING","SQL",...}
thats it
Member 11942465 18-Sep-15 8:17am    
Try this
var result = JsonConvert.DeserializeObject<jsonobject[]>(json);
string jsonnum = string.Join(",", result.Select(x => x.Name).ToArray());

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