Hi folks, can anyone help me to achieve the output like this. i cant able to set the array header like below. suggest me the best way and solution either sample source
My Code:
var groupedCustomerList = _commonService.GetMultilingualDatas(language)
.GroupBy(u => u.screen_name)
.Select(grp => grp.ToList())
.ToList();
string output = Newtonsoft.Json.JsonConvert.SerializeObject(groupedCustomerList);
Actual Result i'm getting:
[
[
{
"multilingual_id": 1,
"screen_name": "splash_screen",
"key": "care_any_ware",
"max_length": 0,
"value": "Care anywhere",
"comments": "",
"language": "en-gb"
}
],
[
{
"multilingual_id": 2,
"screen_name": "login_start",
"key": "log_in",
"max_length": 0,
"value": "Log in",
"comments": "",
"language": "en-gb"
},
{
"multilingual_id": 3,
"screen_name": "login_start",
"key": "join_today",
"max_length": 0,
"value": "Join today",
"comments": "",
"language": "en-gb"
},
{
"multilingual_id": 4,
"screen_name": "login_start",
"key": "take_a_quick_tour",
"max_length": 0,
"value": "Take a quick tour",
"comments": "",
"language": "en-gb"
}
],
Expected Result:
{
"splash_screen": [
{
"key": "care_any_ware",
"max_length": "25",
"value": "Care anywhere",
"value_en": "Care anywhere",
"comments": ""
}
],
<big>"login_start"</big>: [
{
"key": "log_in",
"max_length": "35",
"value": "Log in",
"value_en": "Log in",
"comments": ""
},
{
"key": "join_today",
"max_length": "35",
"value": "Join today",
"value_en": "Join today",
"comments": ""
},
{
"key": "take_a_quick_tour",
"max_length": "35",
"value": "Take a quick tour",
"value_en": "Take a quick tour",
"comments": ""
}
],
What I have tried:
*Tried with list as property in a class
*
Raju's Blog - Creating N-Tier ASP.NET Web API application[
^]
How to get a Name to a Json Array in web API[
^]
few more stackoverflow links