Recursive call for JSON in swift 3 - json

I have a response that looks like this
{
"id": 3,
"parent_id": 1,
"name": "QuickStart Intelligence",
"is_active": true,
"position": 2,
"level": 1,
"product_count": 590,
"children_data": [
{
"id": 53,
"parent_id": 3,
"name": "Find Training",
"is_active": true,
"position": 1,
"level": 2,
"product_count": 9,
"children_data": [
{
"id": 58,
"parent_id": 53,
"name": "Career Paths",
"is_active": true,
"position": 1,
"level": 3,
"product_count": 0,
"children_data": [
{
"id": 123,
"parent_id": 58,
"name": "Business Productivity",
"is_active": true,
"position": 1,
"level": 4,
"product_count": 245,
"children_data": []
},
{
"id": 70,
"parent_id": 58,
"name": "Creative & Design",
"is_active": true,
"position": 3,
"level": 4,
"product_count": 43,
"children_data": []
},
]
},
{
"id": 57,
"parent_id": 53,
"name": "Technology",
"is_active": true,
"position": 2,
"level": 3,
"product_count": 1,
"children_data": [
{
"id": 162,
"parent_id": 57,
"name": "Microsoft",
"is_active": true,
"position": 6,
"level": 4,
"product_count": 183,
"children_data": []
},
{
"id": 164,
"parent_id": 57,
"name": "Adobe",
"is_active": true,
"position": 8,
"level": 4,
"product_count": 34,
"children_data": []
}
]
}
{
"id": 100,
"parent_id": 53,
"name": "Certifications",
"is_active": true,
"position": 3,
"level": 3,
"product_count": 0,
"children_data": [
{
"id": 112,
"parent_id": 100,
"name": "Microsoft SQL Server 2012",
"is_active": true,
"position": 1,
"level": 4,
"product_count": 0,
"children_data": []
},
{
"id": 113,
"parent_id": 100,
"name": "Windows Server 2012 Microsoft Certifications",
"is_active": true,
"position": 2,
"level": 4,
"product_count": 0,
"children_data": []
},
{
"id": 114,
"parent_id": 100,
"name": "Visual Studio Microsoft Certifications",
"is_active": true,
"position": 3,
"level": 4,
"product_count": 0,
"children_data": []
},
{
"id": 115,
"parent_id": 100,
"name": "SharePoint 2013 Microsoft Certifications",
"is_active": true,
"position": 4,
"level": 4,
"product_count": 0,
"children_data": []
},
{
"id": 116,
"parent_id": 100,
"name": "Private Cloud Microsoft Certifications",
"is_active": true,
"position": 5,
"level": 4,
"product_count": 0,
"children_data": []
},
{
"id": 117,
"parent_id": 100,
"name": "Exchange Server 2013 Certifications",
"is_active": true,
"position": 6,
"level": 4,
"product_count": 0,
"children_data": []
},
{
"id": 118,
"parent_id": 100,
"name": "Lync Server 2013 Microsoft Certifications",
"is_active": true,
"position": 7,
"level": 4,
"product_count": 0,
"children_data": []
},
{
"id": 119,
"parent_id": 100,
"name": "Windows 8 Microsoft Certifications",
"is_active": true,
"position": 8,
"level": 4,
"product_count": 0,
"children_data": []
},
{
"id": 120,
"parent_id": 100,
"name": "Microsoft System Center Certifications",
"is_active": true,
"position": 9,
"level": 4,
"product_count": 0,
"children_data": []
},
{
"id": 121,
"parent_id": 100,
"name": "Microsoft Windows Server 2008 Certifications",
"is_active": true,
"position": 10,
"level": 4,
"product_count": 0,
"children_data": []
}
]
}
It goes on like that. I have initialized some variables in my class Categories like this
var categoryId = Int()
var parentId = Int()
var categoryName = String()
var isCategoryActive = Bool()
var categoryPostion = Int()
var categoryLevel = Int()
var categoryChildCount = Int()
var childArray = [Categories]()
I know that it should be done with a recursive call but somehow i am unable to wrap my head around the solution. I've tried looking on overflow but couldn't find anything relevant. this is how i am casting the json
class func getUserFromJson(_ jsonString: String) -> Categories {
let category = Categories()
do {
let dic = try JSONSerialization.jsonObject(with: jsonString.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue))!, options: .allowFragments) as! NSDictionary
if let id = dic.object(forKey: "id") as? Int {
category.categoryId = id
}
if let parentId = dic.object(forKey: "parent_id") as? Int {
category.parentId = parentId
}
if let name = dic.object(forKey: "name") as? String {
category.categoryName = name
}
if let isActive = dic.object(forKey: "is_active") as? Bool {
category.isCategoryActive = isActive
}
if let position = dic.object(forKey: "position") as? Int {
category.categoryPostion = position
}
if let level = dic.object(forKey: "level") as? Int {
category.categoryLevel = level
}
if let productCount = dic.object(forKey: "product_count") as? Int {
category.categoryChildCount = productCount
}
}
catch {
}
return category
}
How would i parse the children_data which is an array and has many children and again those children have children as you can see and some of them are empty so i need to check for that as well.

go like this.
let childrenData = dic["children_data"] as? NSArray
{
for data in childrenData
{
let child_dic = data as! NSDictionary
//Here Your Code.
}
}
You can use same for child of child.

Related

json jq request format

I need help to extract data from this JSON file using jq.
The app flv then verify the streamname mystrame is active and extract meta.video.height
I did try lot of queries without success and my jq knowledge is poor.
{
"port": 1935,
"server_index": 0,
"applications": [{
"name": "hls",
"live": {
"streams": [{
"name": "donbosco",
"time": 2380739,
"bw_in": 2112440,
"bytes_in": 541618713,
"bw_out": 0,
"bytes_out": 0,
"bw_audio": 35544,
"bw_video": 2076888,
"clients": [{
"id": 453,
"address": "127.0.0.1",
"time": 2380959,
"flashver": "FMLE/3.0 (compatible; Lavf57.83.100)",
"dropped": 0,
"avsync": 28,
"timestamp": 2382635,
"publishing": true,
"active": true
}],
"records": [],
"meta": {
"video": {
"width": 1168,
"height": 720,
"frame_rate": 25,
"codec": "H264",
"profile": "High",
"level": 3.1
},
"audio": {
"codec": "AAC",
"profile": "LC",
"channels": 2,
"sample_rate": 16000
}
},
"nclients": 1,
"publishing": true,
"active": true
}],
"nclients": 1
},
"recorders": {
"count": 0,
"lists": []
}
},
{
"name": "flv",
"live": {
"streams": [{
"name": "mystream",
"time": 2382811,
"bw_in": 2059096,
"bytes_in": 541841549,
"bw_out": 2059096,
"bytes_out": 543351459,
"bw_audio": 35472,
"bw_video": 2023624,
"clients": [{
"id": 452,
"address": "127.0.0.1",
"time": 2382727,
"flashver": "LNX 9,0,124,2",
"dropped": 0,
"avsync": -12,
"timestamp": 2384520,
"publishing": false,
"active": true
},
{
"id": 451,
"address": "127.0.0.1",
"time": 2383031,
"flashver": "FMLE/3.0 (compatible; Lavf58.74.100)",
"dropped": 0,
"avsync": -12,
"timestamp": 2384520,
"publishing": true,
"active": true
}
],
"records": [],
"meta": {
"video": {
"width": 1168,
"height": 720,
"frame_rate": 25,
"codec": "H264",
"profile": "High",
"level": 3.1
},
"audio": {
"codec": "AAC",
"profile": "LC",
"channels": 2,
"sample_rate": 16000
}
},
"nclients": 2,
"publishing": true,
"active": true
}],
"nclients": 2
},
"recorders": {
"count": 0,
"lists": []
}
}
]
}
Are you asking for help with the command-line JSON processor jq or the JavaScript library jQuery? They are not the same. For jq, try
jq '
.applications
| map(select(.name == "flv"))[].live.streams
| map(select(.name == "mystream" and .active))[].meta.video.height
'
720
Demo

ORDER condition not working in cakephp 3 TREE behavior

I am using cakephp-3 tree behavior for Categories table. Here 'sequence_no' field are using to sorting sub-category list for a category. I am searching with a category_id to get all of his child category in ASCENDING order by 'sequence_no'. But order not working here. My code snippet and output here.
$categoris = $this->Categories->find('children', ['for' => $id])
->find('threaded')
->contain('ParentCategories')
->order(['Categories.sequence_no' => 'ASC'])
->toArray();
- OUTPUT SAMPLE:
{
"status": "OK",
"result": {
"data": [
{
"id": 15,
"store_id": 0,
"uuid": null,
"name": "cat-3",
"parent_id": 3,
"lft": 16,
"rght": 17,
"sequence_no": 2,
"url": "cat-3",
"layout_id": 0,
"status": 1,
"total": 0,
"created": "2018-06-12T07:36:15+00:00",
"modified": "2018-06-12T08:15:12+00:00",
"parent_category": {
"id": 3,
"store_id": 2,
"uuid": null,
"name": "Pants",
"parent_id": null,
"lft": 15,
"rght": 20,
"sequence_no": null,
"url": "pants",
"layout_id": 0,
"status": 1,
"total": 0,
"created": "2018-06-06T10:23:50+00:00",
"modified": "2018-06-06T10:23:50+00:00"
},
"children": []
},
{
"id": 16,
"store_id": 0,
"uuid": null,
"name": "cat-4",
"parent_id": 3,
"lft": 18,
"rght": 19,
"sequence_no": 1,
"url": "cat-4",
"layout_id": 0,
"status": 1,
"total": 0,
"created": "2018-06-12T07:36:34+00:00",
"modified": "2018-06-12T08:15:12+00:00",
"parent_category": {
"id": 3,
"store_id": 2,
"uuid": null,
"name": "Pants",
"parent_id": null,
"lft": 15,
"rght": 20,
"sequence_no": null,
"url": "pants",
"layout_id": 0,
"status": 1,
"total": 0,
"created": "2018-06-06T10:23:50+00:00",
"modified": "2018-06-06T10:23:50+00:00"
},
"children": []
}
]
}
}
Since findChildred finder add a ORDER lft asc clause to your query your order conditions will be appended to that
If you want to force your order you can do
->order(['Categories.sequence_no' => 'ASC'], true)
the second parameter in the order() method tells cake to overwrite the ORDER BY set before
see the manual, about the end of this paragraph

Golang custom unmarshalling nested JSON

I have a JSON object that looks like this. It contains 3 meals a day for one week, for 21 total entries, since each meal is an individual entry.
{
"name": "MealPlan 1508620645147",
"items": [
{
"day": 1,
"mealPlanId": 0,
"slot": 1,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":869953,\"imageType\":\"jpg\",\"title\":\"Cream Cheese & Fruit Breakfast Pastries\"}"
},
{
"day": 1,
"mealPlanId": 0,
"slot": 2,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":537176,\"imageType\":\"jpg\",\"title\":\"Leftover Rice Casserole\"}"
},
{
"day": 1,
"mealPlanId": 0,
"slot": 3,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":595927,\"imageType\":\"jpg\",\"title\":\"Spinach and Cheddar Quiche\"}"
},
{
"day": 2,
"mealPlanId": 0,
"slot": 1,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":536716,\"imageType\":\"jpg\",\"title\":\"Candied Pecan Waffles\"}"
},
{
"day": 2,
"mealPlanId": 0,
"slot": 2,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":893265,\"imageType\":\"jpg\",\"title\":\"Tahini Date Smoothie Bowls\"}"
},
{
"day": 2,
"mealPlanId": 0,
"slot": 3,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":512880,\"imageType\":\"jpg\",\"title\":\"Grilled Caprese Salad Sandwich for #SundaySupper\"}"
},
{
"day": 3,
"mealPlanId": 0,
"slot": 1,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":648647,\"imageType\":\"jpg\",\"title\":\"Jumbo Blueberry Muffins\"}"
},
{
"day": 3,
"mealPlanId": 0,
"slot": 2,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":548554,\"imageType\":\"jpg\",\"title\":\"Brie, Pesto, and Sweet Pepper Grilled Cheese\"}"
},
{
"day": 3,
"mealPlanId": 0,
"slot": 3,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":438024,\"imageType\":\"jpg\",\"title\":\"Mother's Manicotti\"}"
},
{
"day": 4,
"mealPlanId": 0,
"slot": 1,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":681594,\"imageType\":\"jpg\",\"title\":\"Huevos Rancheros\"}"
},
{
"day": 4,
"mealPlanId": 0,
"slot": 2,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":99184,\"imageType\":\"jpg\",\"title\":\"Black Bean Tacos\"}"
},
{
"day": 4,
"mealPlanId": 0,
"slot": 3,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":604514,\"imageType\":\"jpg\",\"title\":\"Cheddar Scallion Dutch Baby\"}"
},
{
"day": 5,
"mealPlanId": 0,
"slot": 1,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":622672,\"imageType\":\"jpg\",\"title\":\"Cinnamon-Sugar Streusel Baked French Toast\"}"
},
{
"day": 5,
"mealPlanId": 0,
"slot": 2,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":636178,\"imageType\":\"jpg\",\"title\":\"Broccoli Cheddar Soup, A Panera Bread Co. Copycat\"}"
},
{
"day": 5,
"mealPlanId": 0,
"slot": 3,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":452482,\"imageType\":\"jpg\",\"title\":\"Slow Cooker Macaroni and Cheese I\"}"
},
{
"day": 6,
"mealPlanId": 0,
"slot": 1,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":157272,\"imageType\":\"jpg\",\"title\":\"Pomegranate-Nutella Waffles\"}"
},
{
"day": 6,
"mealPlanId": 0,
"slot": 2,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":619111,\"imageType\":\"jpg\",\"title\":\"Barley, Bulgur and Vegetable Vegan Casserole\"}"
},
{
"day": 6,
"mealPlanId": 0,
"slot": 3,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":510089,\"imageType\":\"jpg\",\"title\":\"Stovetop Mac and Cheese\"}"
},
{
"day": 7,
"mealPlanId": 0,
"slot": 1,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":551869,\"imageType\":\"jpg\",\"title\":\"Berry Smoothie\"}"
},
{
"day": 7,
"mealPlanId": 0,
"slot": 2,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":590452,\"imageType\":\"jpg\",\"title\":\"Cheesy Baked Pasta with Eggplant and Artichokes\"}"
},
{
"day": 7,
"mealPlanId": 0,
"slot": 3,
"position": 0,
"type": "RECIPE",
"value": "{\"id\":590452,\"imageType\":\"jpg\",\"title\":\"Cheesy Baked Pasta with Eggplant and Artichokes\"}"
}
]
}
I want to unmarshal it into an array of structs that will hold 3 meals each as Breakfast, Lunch, Dinner. So, I want my struct to look like this, where ID is the value.id field from the JSON, and Name is the value.title field from the JSON, Breakfast is the item with slot:1, Lunch is the item with slot:2 and Dinner is the item with slot:3.
type Day struct {
Breakfast meal
Lunch meal
Dinner meal
}
type meal struct {
ID int
Name string
}
How can I accomplish this in Go? My initial thought was to create an intermediate struct that holds all the data from the JSON, and then create another struct by using just the fields I need. How can I do this without using the intermediary struct ?
Did as mayo suggested and implemented UnmarshalJSON
func (wp *WeekPlan) UnmarshalJSON(b []byte) error {
wp.Days = make([]Day, 7)
var f map[string]*json.RawMessage
json.Unmarshal(b, &f)
var v []map[string]interface{}
json.Unmarshal(*f["items"], &v)
for _, item := range v {
day := int(item["day"].(float64)) - 1
mealnumber := int(item["slot"].(float64))
var value map[string]interface{}
json.Unmarshal([]byte(item["value"].(string)), &value)
fmt.Println(value)
id := int(value["id"].(float64))
name := value["title"].(string)
thisMeal := Meal{ID: id, Name: name}
var dateUpdate Day
dateUpdate = wp.Days[day]
switch mealnumber {
case 1:
dateUpdate.Breakfast = thisMeal
case 2:
dateUpdate.Lunch = thisMeal
default:
dateUpdate.Dinner = thisMeal
}
wp.Days[day] = dateUpdate
}
return nil
}
type WeekPlan struct {
Days []Day
}
type Day struct {
Breakfast Meal
Lunch Meal
Dinner Meal
}
type Meal struct {
ID int
Name string
CookTime int
Image string
}

How can group by or merge my json object based on common property in angular4 project

I have this json object in my angular4 project. I want to group by or merge this object based on common property.
How can merge these object based on fixture_desc? I want to display as fixture_desc= "Pepsi Cooler" and under it all items.
"items": [
{
"barcode": "052000324815",
"price": 2,
"taxable": false,
"description": "Gatorade Cool Blue",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Pepsi Cooler"
},
{
"barcode": "052000328660",
"price": 2,
"taxable": false,
"description": "Gatorade Fruit Punch ",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Pepsi Cooler",
"min": 2,
"max": 8,
"_id": "58feb29a3a5c560011b1b96c"
},
{
"barcode": "052000328684",
"price": 2,
"taxable": false,
"description": "Gatorade Lemon Lime ",
"tax_rate": 0,
"inventory": 4,
"fixture_desc": "Pepsi Cooler",
"min": 1,
"max": 4,
}
]
I want to make organise to display my data. My expected result is like this :
"items": [
{
"name": "Pepsi Cooler”,
"items": [
{
"barcode": "052000324815",
"price": 2,
"taxable": false,
"description": "Gatorade Cool Blue",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Pepsi Cooler"
},
{
"barcode": "052000328660",
"price": 2,
"taxable": false,
"description": "Gatorade Fruit Punch ",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Pepsi Cooler"
}
]
}
{
"name": “Cook Cooler”,
"items": [
{
"barcode": "052000324815",
"price": 2,
"taxable": false,
"description": "Gatorade Cool Blue",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Cook Cooler
},
{
"barcode": "052000328660",
"price": 2,
"taxable": false,
"description": "Gatorade Fruit Punch ",
"tax_rate": 0,
"inventory": 8,
"fixture_desc": "Cook Cooler
}
]
}
]
I solved my problem. I am posting it if its help anyone.
Here my Array:
var myobj={"items": [
{
"barcode": "052000324815",
"description": "Gatorade Cool Blue",
"fixture_desc": "Pepsi Cooler"
},
{
"barcode": "052000328660",
"description": "Gatorade Fruit Punch ",
"fixture_desc": "Pepsi Cooler",
},
{
"barcode": "052000328684",
"description": "Gatorade Lemon Lime ",
"fixture_desc": "Pepsi Cooler",
}
]
}
and this is my solution:
result:any[] = [];
finalResult(myObj:any){
var Obj = myObj;
var groups:any[]=[];
for (let a of Obj) {
groups[a.fixture_desc] = groups[a.fixture_desc] || {
name:a.fixture_desc,
items:[],
isfixtureExpanded:false
};
groups[a.fixture_desc].items.push({
barcode: a.barcode,
description: a.description,
fixture_desc:a.fixture_desc,
});
}
for (var key in groups){
this.result.push(groups[key]);
}
}
console.log(this.result);
}
Instead of asking the code you can show us whatever you have done to achieve it, SO is not code generator. But anyway here's the code that can do the same you wanted.
function group(array, prop) {
var result = [];
array.forEach(function(val) {
var found = false;
for(var i=0;i<result.length;i++) {
if(result[i].name === val[prop]) {
result[i].items.push(val);
found = true;
}
}
});
}
Call it as
var finalResult = group(items,'fixture_desc');

Getting error while parsing json response from a dynamic {System.RuntimeType} variable

I'm working on some code in which uses dynamic variables jsonResponse .
dynamic jsonResponse = JsonConvert.DeserializeObject(response);
This variable contains collection of hotel list in json format. From this collection I am getting roomlist collection in a new variable roomResponseList :
var roomResponseList = jsonResponse["hotels"]["hotels"][rooms].roomResponseList;
I am getting first room detail into **JObject responseRateKeys **:
foreach (var roomByResponse in roomResponseList)
{
JObject responseRateKeys = JObject.Parse(roomByResponse.ToString());
var boardNameListByResponse = responseRateKeys.AsJEnumerable().AsEnumerable()
.Select(t => t["rates"]["boardName"].ToString().Trim())
.Distinct()
.ToList();
}
But when I am trying to get any item list from JObject by using linq lambda, I am getting error,
"Cannot access child value on Newtonsoft.Json.Linq.JProperty."
Value of roomByResponse=
{ "code": "DBL.KG-NM", "name": "DOUBLE KING BED NON SMOKING", "rates": [ { "rateKey": "20171217|20171219|W|256|237403|DBL.KG-NM|ID_B2B_26|RO|IWH25|1~1~0||N#AFF5C93E36054661ADCBC14A78A532AE1007", "rateClass": "NRF", "rateType": "RECHECK", "net": "186.04", "allotment": 99, "paymentType": "AT_WEB", "packaging": false, "boardCode": "RO", "boardName": "ROOM ONLY", "cancellationPolicies": [ { "amount": "149.63", "from": "2017-07-14T03:29:00+05:30" } ], "rooms": 1, "adults": 1, "children": 0, "dailyRates": [ { "offset": 1, "dailyNet": "93.02" }, { "offset": 2, "dailyNet": "93.02" } ] }, { "rateKey": "20171217|20171219|W|256|237403|DBL.KG-NM|ID_B2B_26|BB|IWB25|1~1~0||N#AFF5C93E36054661ADCBC14A78A532AE1007", "rateClass": "NOR", "rateType": "RECHECK", "net": "238.92", "allotment": 99, "paymentType": "AT_WEB", "packaging": false, "boardCode": "BB", "boardName": "BED AND BREAKFAST", "rooms": 1, "adults": 1, "children": 0, "dailyRates": [ { "offset": 1, "dailyNet": "119.46" }, { "offset": 2, "dailyNet": "119.46" } ] }, { "rateKey": "20171217|20171219|W|256|237403|DBL.KG-NM|ID_B2B_26|RO|IWH25|2~2~1|2|N#AFF5C93E36054661ADCBC14A78A532AE1007", "rateClass": "NRF", "rateType": "RECHECK", "net": "372.06", "allotment": 99, "paymentType": "AT_WEB", "packaging": false, "boardCode": "RO", "boardName": "ROOM ONLY", "cancellationPolicies": [ { "amount": "299.25", "from": "2017-07-14T03:29:00+05:30" } ], "rooms": 2, "adults": 2, "children": 1, "childrenAges": "2", "dailyRates": [ { "offset": 1, "dailyNet": "186.03" }, { "offset": 2, "dailyNet": "186.03" } ] }, { "rateKey": "20171217|20171219|W|256|237403|DBL.KG-NM|ID_B2B_26|BB|IWB25|2~2~1|2|N#AFF5C93E36054661ADCBC14A78A532AE1007", "rateClass": "NOR", "rateType": "RECHECK", "net": "477.84", "allotment": 99, "paymentType": "AT_WEB", "packaging": false, "boardCode": "BB", "boardName": "BED AND BREAKFAST", "rooms": 2, "adults": 2, "children": 1, "childrenAges": "2", "dailyRates": [ { "offset": 1, "dailyNet": "238.92" }, { "offset": 2, "dailyNet": "238.92" } ] } ] }
Thank you
Pravesh Singh
change linq to
responseRateKeys["rates"].AsJEnumerable().Select(t=>t["boardName"]).Distinct().ToList()