Run one program from another, Raspberry Pi 2 Windows 10 IoT - raspberry-pi2

I spent several hours to find answer for my question. I am so tired, so I give up and ask You for help.
Is there any way to check installed programs on raspberry pi (with windows 10 iot) from c# code?
I need to do simple ListView with installed programs and run if one is clicked.

Just a thought - the Win 10 Core has a browser/web server interface.
http://...:8080
There is a menu option for listing all the loaded/installed apps on the RPI2.
Can you run a network trace to see the call the browser page is making to get the list of apps?
http://minwinpc:8080/api/resourcemanager/processes
(you maybe prompted to login - I wasnt)
This what I see from my machine.
{
"Processes": [
{
"CPUUsage": 96.289954,
"ImageName": "System Idle Process",
"PrivateWorkingSet": 8192,
"ProcessId": 0,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 0,
"WorkingSetSize": 8192
},
{
"CPUUsage": 0,
"ImageName": "System",
"PrivateWorkingSet": 8192,
"ProcessId": 4,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 1404928,
"WorkingSetSize": 65536
},
{
"CPUUsage": 0,
"ImageName": "smss.exe",
"PrivateWorkingSet": 110592,
"ProcessId": 228,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 3330048,
"WorkingSetSize": 765952
},
{
"AppName": "IoTCoreDefaultApp",
"CPUUsage": 0,
"ImageName": "IoTCoreDefaultApp.exe",
"PackageFullName": "IoTCoreDefaultApp_5.0.0.0_arm__kwmcxzszfer2y",
"PrivateWorkingSet": 4927488,
"ProcessId": 244,
"SessionId": 0,
"UserName": "MINWINPC\\DefaultAccount",
"VirtualSize": 183427072,
"WorkingSetSize": 33046528
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 811008,
"ProcessId": 272,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 29102080,
"WorkingSetSize": 4833280
},
{
"CPUUsage": 0,
"ImageName": "csrss.exe",
"PrivateWorkingSet": 253952,
"ProcessId": 416,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 12075008,
"WorkingSetSize": 1548288
},
{
"CPUUsage": 0,
"ImageName": "wininit.exe",
"PrivateWorkingSet": 421888,
"ProcessId": 472,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 14802944,
"WorkingSetSize": 2813952
},
{
"CPUUsage": 0,
"ImageName": "services.exe",
"PrivateWorkingSet": 1163264,
"ProcessId": 516,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 10252288,
"WorkingSetSize": 3682304
},
{
"CPUUsage": 0,
"ImageName": "lsass.exe",
"PrivateWorkingSet": 1830912,
"ProcessId": 540,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 28164096,
"WorkingSetSize": 7823360
},
{
"CPUUsage": 0,
"ImageName": "dwm.exe",
"PrivateWorkingSet": 16900096,
"ProcessId": 608,
"SessionId": 0,
"UserName": "Window Manager\\DWM-0",
"VirtualSize": 68108288,
"WorkingSetSize": 25849856
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 1437696,
"ProcessId": 660,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 33079296,
"WorkingSetSize": 8138752
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 1028096,
"ProcessId": 700,
"SessionId": 0,
"UserName": "NT AUTHORITY\\NETWORK SERVICE",
"VirtualSize": 19726336,
"WorkingSetSize": 4333568
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 3219456,
"ProcessId": 800,
"SessionId": 0,
"UserName": "NT AUTHORITY\\LOCAL SERVICE",
"VirtualSize": 44740608,
"WorkingSetSize": 9203712
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 3878912,
"ProcessId": 836,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 69656576,
"WorkingSetSize": 15163392
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 2367488,
"ProcessId": 868,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 53243904,
"WorkingSetSize": 9957376
},
{
"CPUUsage": 0,
"ImageName": "msvsmon.exe",
"PrivateWorkingSet": 262144,
"ProcessId": 888,
"SessionId": 0,
"UserName": "MINWINPC\\DefaultAccount",
"VirtualSize": 23502848,
"WorkingSetSize": 1650688
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 2801664,
"ProcessId": 896,
"SessionId": 0,
"UserName": "NT AUTHORITY\\LOCAL SERVICE",
"VirtualSize": 94810112,
"WorkingSetSize": 10928128
},
{
"CPUUsage": 0,
"ImageName": "SearchIndexer.exe",
"PrivateWorkingSet": 2387968,
"ProcessId": 908,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 66920448,
"WorkingSetSize": 7434240
},
{
"CPUUsage": 0,
"ImageName": "RuntimeBroker.exe",
"PrivateWorkingSet": 806912,
"ProcessId": 928,
"SessionId": 0,
"UserName": "MINWINPC\\DefaultAccount",
"VirtualSize": 22798336,
"WorkingSetSize": 5750784
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 2805760,
"ProcessId": 1016,
"SessionId": 0,
"UserName": "NT AUTHORITY\\NETWORK SERVICE",
"VirtualSize": 41480192,
"WorkingSetSize": 9691136
},
{
"CPUUsage": 0,
"ImageName": "msvsmon.exe",
"PrivateWorkingSet": 266240,
"ProcessId": 1068,
"SessionId": 0,
"UserName": "MINWINPC\\DefaultAccount",
"VirtualSize": 18898944,
"WorkingSetSize": 1466368
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 557056,
"ProcessId": 1104,
"SessionId": 0,
"UserName": "NT AUTHORITY\\LOCAL SERVICE",
"VirtualSize": 16863232,
"WorkingSetSize": 3424256
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorking`enter code here`Set": 2711552,
"ProcessId": 1256,
"SessionId": 0,
"UserName": "NT AUTHORITY\\LOCAL SERVICE",
"VirtualSize": 41779200,
"WorkingSetSize": 8491008
},
{
"CPUUsage": 0,
"ImageName": "ebootpinger.exe",
"PrivateWorkingSet": 274432,
"ProcessId": 1372,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 9142272,
"WorkingSetSize": 1241088
},
{
"CPUUsage": 0,
"ImageName": "ftpd.exe",
"PrivateWorkingSet": 163840,
"ProcessId": 1396,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 8114176,
"WorkingSetSize": 1019904
},
{
"CPUUsage": 0,
"ImageName": "sihost.exe",
"PrivateWorkingSet": 3575808,
"ProcessId": 1416,
"SessionId": 0,
"UserName": "MINWINPC\\DefaultAccount",
"VirtualSize": 69918720,
"WorkingSetSize": 20426752
},
{
"CPUUsage": 0,
"ImageName": "WebB.exe",
"PrivateWorkingSet": 1523712,
"ProcessId": 1504,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 25554944,
"WorkingSetSize": 5910528
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 4005888,
"ProcessId": 1560,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 72216576,
"WorkingSetSize": 13217792
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 540672,
"ProcessId": 1592,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 16191488,
"WorkingSetSize": 3182592
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 802816,
"ProcessId": 1644,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 34844672,
"WorkingSetSize": 5726208
},
{
"CPUUsage": 0,
"ImageName": "svchost.exe",
"PrivateWorkingSet": 1015808,
"ProcessId": 1752,
"SessionId": 0,
"UserName": "NT AUTHORITY\\SYSTEM",
"VirtualSize": 29413376,
"WorkingSetSize": 5304320
}
]
}
HTH,
Mick.

Related

How to apply multiple colors in legend for Vega stacked bar?

I have the next Vega-Light bar chart.
Vega Bar online editor
How to apply multiple colors in legend? When I apply
symbols: {
update: {
fill: { field: 'color' },
},
},
I didn't see any symbols, only labels.
I need to apply four colors for legend symbols. When I write fill: { value : "red"}, all of the symbols became red color. I need that the four symbols to have different colors. How I can fix this?
{
"width": 500,
"height": 200,
"title": "STD: cashflow cleaning",
"data": [
{
"name": "table",
"values": [
{"yearIndex": 1, "c": "red", "y": 100000, "y0": 10000, "y1": 110000},
{"yearIndex": 1, "c": "green", "y": 10000, "y0": 0, "y1": 10000},
{"yearIndex": 1, "c": "blue", "y": -12000, "y0": 0, "y1": -12000},
{
"yearIndex": 1,
"c": "orange",
"y": -110000,
"y0": -12000,
"y1": -122000
},
{"yearIndex": 2, "c": "red", "y": 980000, "y0": 98000, "y1": 1078000},
{"yearIndex": 2, "c": "green", "y": 98000, "y0": 0, "y1": 98000},
{"yearIndex": 2, "c": "blue", "y": -10000, "y0": 0, "y1": -10000},
{"yearIndex": 2, "c": "orange", "y": 0, "y0": 98000, "y1": 98000},
{"yearIndex": 3, "c": "red", "y": 960000, "y0": 96000, "y1": 1056000},
{"yearIndex": 3, "c": "green", "y": 96000, "y0": 0, "y1": 96000},
{"yearIndex": 3, "c": "blue", "y": -12000, "y0": 0, "y1": -12000},
{"yearIndex": 3, "c": "orange", "y": 0, "y0": 96000, "y1": 96000},
{"yearIndex": 4, "c": "red", "y": 940000, "y0": 94000, "y1": 1034000},
{"yearIndex": 4, "c": "green", "y": 94000, "y0": 0, "y1": 94000},
{"yearIndex": 4, "c": "blue", "y": -10000, "y0": 0, "y1": -10000},
{"yearIndex": 4, "c": "orange", "y": 0, "y0": 94000, "y1": 94000},
{"yearIndex": 5, "c": "red", "y": 920000, "y0": 92000, "y1": 1012000},
{"yearIndex": 5, "c": "green", "y": 92000, "y0": 0, "y1": 92000},
{"yearIndex": 5, "c": "blue", "y": -12000, "y0": 0, "y1": -12000},
{"yearIndex": 5, "c": "orange", "y": 0, "y0": 92000, "y1": 92000},
{"yearIndex": 6, "c": "red", "y": 900000, "y0": 90000, "y1": 990000},
{"yearIndex": 6, "c": "green", "y": 90000, "y0": 0, "y1": 90000},
{"yearIndex": 6, "c": "blue", "y": -10000, "y0": 0, "y1": -10000},
{
"yearIndex": 6,
"c": "orange",
"y": -91000,
"y0": -10000,
"y1": -101000
},
{"yearIndex": 7, "c": "red", "y": 880000, "y0": 88000, "y1": 968000},
{"yearIndex": 7, "c": "green", "y": 88000, "y0": 0, "y1": 88000},
{"yearIndex": 7, "c": "blue", "y": -12000, "y0": 0, "y1": -12000},
{"yearIndex": 7, "c": "orange", "y": 0, "y0": 88000, "y1": 88000},
{"yearIndex": 8, "c": "red", "y": 860000, "y0": 86000, "y1": 946000},
{"yearIndex": 8, "c": "green", "y": 86000, "y0": 0, "y1": 86000},
{"yearIndex": 8, "c": "blue", "y": -10000, "y0": 0, "y1": -10000},
{"yearIndex": 8, "c": "orange", "y": 0, "y0": 86000, "y1": 86000},
{"yearIndex": 9, "c": "red", "y": 840000, "y0": 84000, "y1": 924000},
{"yearIndex": 9, "c": "green", "y": 84000, "y0": 0, "y1": 84000},
{"yearIndex": 9, "c": "blue", "y": -12000, "y0": 0, "y1": -12000},
{"yearIndex": 9, "c": "orange", "y": 0, "y0": 84000, "y1": 84000},
{"yearIndex": 10, "c": "red", "y": 820000, "y0": 82000, "y1": 902000},
{"yearIndex": 10, "c": "green", "y": 82000, "y0": 0, "y1": 82000},
{"yearIndex": 10, "c": "blue", "y": -10000, "y0": 0, "y1": -10000},
{"yearIndex": 10, "c": "orange", "y": 0, "y0": 82000, "y1": 82000}
],
"transform": [
{
"type": "stack",
"groupby": ["yearIndex"],
"sort": {"field": "c"},
"field": "y"
}
]
}
],
"scales": [
{
"name": "x",
"type": "band",
"range": "width",
"domain": {"data": "table", "field": "yearIndex"}
},
{
"name": "y",
"type": "linear",
"range": "height",
"nice": true,
"zero": true,
"domain": {"data": "table", "field": "y1"}
},
{
"name": "color",
"type": "ordinal",
"range": {"data": "table", "field": "c"},
"domain": [
"basicYieldIncome",
"avoidedSoilingIncomeLoss",
"opex",
"capex"
]
}
],
"axes": [
{"orient": "bottom", "scale": "x", "zindex": 1, "title": "yearIndex"},
{
"orient": "left",
"scale": "y",
"zindex": 1,
"title": "EUR",
"formatType": "number",
"format": ".2s"
}
],
"marks": [
{
"type": "rect",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "yearIndex"},
"width": {"scale": "x", "band": 1, "offset": -1},
"y": {"scale": "y", "field": "y0"},
"y2": {"scale": "y", "field": "y1"},
"fill": {"field": "c"}
}
}
}
],
"legends": [
{
"orient": "top",
"direction": "horizontal",
"fill": "color",
"encode": {
"labels": {
"interactive": true,
"update": {"fontSize": {"value": 12}, "fill": {"value": "black"}}
}
}
}
]
}

How add product with pick_list modifier to cart

What is the appropriate syntax to add a sku with picklist modifiers to cart?
https://developer.bigcommerce.com/api-reference/cart-checkout/storefront-cart-api/cart/addcartlineitem
Assuming this is my product
GET https://api.bigcommerce.com/stores/:store-hash/v3/catalog/products?include=modifiers,variants&id:in=237
{
"data": [
{
"id": 237,
"name": "Awesome Bundle Sku",
"type": "physical",
"sku": "BUNDLE1",
"description": "",
"weight": 1,
"width": 1,
"depth": 1,
"height": 1,
"price": 99,
"cost_price": 0,
"retail_price": 0,
"sale_price": 0,
"map_price": 0,
"tax_class_id": 0,
"product_tax_code": "",
"calculated_price": 99,
"categories": [
50
],
"brand_id": 0,
"option_set_id": 25,
"option_set_display": "right",
"inventory_level": 0,
"inventory_warning_level": 0,
"inventory_tracking": "none",
"reviews_rating_sum": 0,
"reviews_count": 0,
"total_sold": 0,
"fixed_cost_shipping_price": 0,
"is_free_shipping": false,
"is_visible": false,
"is_featured": false,
"related_products": [
-1
],
"warranty": "",
"bin_picking_number": "",
"layout_file": "product.html",
"upc": "",
"mpn": "",
"gtin": "",
"search_keywords": "",
"availability": "available",
"availability_description": "",
"gift_wrapping_options_type": "any",
"gift_wrapping_options_list": [],
"sort_order": 500,
"condition": "New",
"is_condition_shown": false,
"order_quantity_minimum": 0,
"order_quantity_maximum": 0,
"page_title": "",
"meta_keywords": [],
"meta_description": "",
"date_created": "2019-05-29T19:16:08+00:00",
"date_modified": "2019-08-24T19:28:45+00:00",
"view_count": 0,
"preorder_release_date": null,
"preorder_message": "",
"is_preorder_only": false,
"is_price_hidden": false,
"price_hidden_label": "",
"custom_url": {
"url": "/bundle1/",
"is_customized": false
},
"base_variant_id": 202,
"open_graph_type": "product",
"open_graph_title": "",
"open_graph_description": "",
"open_graph_use_meta_description": true,
"open_graph_use_product_name": true,
"open_graph_use_image": true,
"variants": [
{
"id": 202,
"product_id": 237,
"sku": "BUNDLE1",
"sku_id": null,
"price": 99,
"calculated_price": 99,
"sale_price": 0,
"retail_price": 0,
"map_price": 0,
"weight": 1,
"width": 1,
"height": 1,
"depth": 1,
"is_free_shipping": false,
"fixed_cost_shipping_price": 0,
"calculated_weight": 1,
"purchasing_disabled": false,
"purchasing_disabled_message": "",
"image_url": "",
"cost_price": 0,
"upc": "",
"mpn": "",
"gtin": "",
"inventory_level": 0,
"inventory_warning_level": 0,
"bin_picking_number": "",
"option_values": []
}
],
"modifiers": [
{
"id": 140,
"product_id": 237,
"name": "53701567688198-237",
"display_name": "5370",
"type": "product_list",
"required": true,
"sort_order": 1,
"config": {
"product_list_adjusts_inventory": false,
"product_list_adjusts_pricing": false,
"product_list_shipping_calc": "none"
},
"option_values": [
{
"id": 127,
"option_id": 140,
"label": "COMPONENT1",
"sort_order": 0,
"value_data": {
"product_id": 136
},
"is_default": true,
"adjusters": {
"price": null,
"weight": null,
"image_url": "",
"purchasing_disabled": {
"status": false,
"message": ""
}
}
}
]
}
]
}
],
"meta": {
"pagination": {
"total": 1,
"count": 1,
"per_page": 250,
"current_page": 1,
"total_pages": 1,
"links": {
"current": "?limit=250&include=modifiers%2Cvariants&id%3Ain=237&page=1"
},
"too_many": false
}
}
}
POST https://api.bigcommerce.com/stores/:store-hash/v3/carts/:cart-id/items
{
"line_items": [
{
"product_id": 237,
"quantity": 1,
"option_selections": [
{
"option_id": 140,
"option_value": 127
}
]
}
]
}

What causes the layout problems of my Datatable?

I am building an app in which I want use Datatables with various plugins and I observed some weird layout-problems. So I tried to build a repro. And as worked on that, new problems occurred and I even failed to sort these out.
So here I am with the current state of my fiddle
I have no idea what's causing these issues. I have attached a bit of code (because it is required, but with reduced data). The issues I'm currently struggling with:
yadcf-Filters incomplete...
footer-defects: pagelength-selector missing, paging-controls missing. Whenever I saw that in the past, there were some JS-Errors (usually with my code), but this time I'm not seeing anything in the console.
Update1: I've now managed to get rid of column1-resizing. The range_number_sliderfor yadcf does not render correctly - am I missing a resource??
Updated fiddle here.
$(function() {
dtObj = $("#dataset").DataTable({
"buttons": [{
"columns": ":gt(1)",
"extend": "colvis",
"text": "Series"
}],
"scrollX": true,
"dom": "Bfrtip",
"lengthMenu": [
[10, 25, 50, -1],
["10 rows", "25 rows", "50 rows", "Show all"]
],
"columns": [{
"data": "_include",
"render": function(data, type, row, meta) {
var res = '';
if (row._include) {
res='<span onclick="toggleRecord(' + row._id + ')"><i class="fal fa-eye"></i></span>';
} else {
res='<span onclick="toggleRecord(' + row._id + ')"><i class="fal fa-eye-slash"></i></span>';
}
return res;
},
"title": "Include",
"visible": true,
"width": "2em;"
}, {
"data": "_id",
"title": "ID",
"visible": false
}, {
"className": "text-right",
"data": "Car",
"title": "Car",
"visible": false,
"width": "80px"
}, {
"data": "Eyes",
"title": "Eyes",
"visible": false,
"width": "80px"
}, {
"className": "text-right",
"data": "Family",
"title": "Family",
"visible": false,
"width": "80px"
}, {
"data": "Hand",
"title": "Hand",
"visible": true,
"width": "80px"
}, {
"className": "text-right",
"data": "HealthCare",
"title": "HealthCare",
"visible": false,
"width": "80px"
}, {
"className": "text-right",
"data": "Height",
"title": "Height",
"visible": true,
"width": "80px"
}, {
"data": "Major",
"title": "Major",
"visible": true,
"width": "80px"
}, {
"className": "text-right",
"data": "Marriage",
"title": "Marriage",
"visible": false,
"width": "80px"
}, {
"data": "Party",
"title": "Party",
"visible": false,
"width": "80px"
}, {
"className": "text-right",
"data": "Pot",
"title": "Pot",
"visible": false,
"width": "80px"
}, {
"data": "Sex",
"title": "Sex",
"visible": false,
"width": "80px"
}, {
"className": "text-right",
"data": "ShoeSize",
"title": "ShoeSize",
"visible": false,
"width": "80px"
}, {
"data": "State",
"title": "State",
"visible": true,
"width": "80px"
}, {
"className": "text-right",
"data": "Student",
"title": "Student",
"visible": false,
"width": "80px"
}, {
"className": "text-right",
"data": "Weight",
"title": "Weight",
"visible": false,
"width": "80px"
}],
"createdRow": function(row, data, dataIndex) {
row.id = 'r' + data._id;
if (!data._include) {
$(row).children(":gt(2)").addClass('excludeRow');
}
},
"data": [{
"Car": 1,
"Eyes": "Blue",
"Family": 3,
"Hand": "R",
"HealthCare": 2,
"Height": 72,
"Major": "FIN",
"Marriage": 5,
"Party": "R",
"Pot": 4,
"Sex": "M",
"ShoeSize": 11.5,
"State": "PA",
"Student": 1,
"Weight": 220,
"_id": 1,
"_include": true
}, {
"Car": 1,
"Eyes": "Brown",
"Family": 4,
"Hand": "R",
"HealthCare": 1,
"Height": 62,
"Major": "ACC",
"Marriage": 1,
"Party": "D",
"Pot": 5,
"Sex": "F",
"ShoeSize": 9,
"State": "PA",
"Student": 2,
"Weight": 140,
"_id": 2,
"_include": true
}, {
"Car": 0,
"Eyes": "Blue",
"Family": 0,
"Hand": "R",
"HealthCare": 3,
"Height": 69,
"Major": "FIN",
"Marriage": 1,
"Party": "D",
"Pot": 4,
"Sex": "M",
"ShoeSize": 11,
"State": "MD",
"Student": 3,
"Weight": 195,
"_id": 3,
"_include": true
}, {
"Car": 1,
"Eyes": "Blue",
"Family": 1,
"Hand": "R",
"HealthCare": 2,
"Height": 69,
"Major": "OIM",
"Marriage": 1,
"Party": "D",
"Pot": 3,
"Sex": "M",
"ShoeSize": 9.5,
"State": "PA",
"Student": 4,
"Weight": 190,
"_id": 4,
"_include": true
}, {
"Car": 1,
"Eyes": "Brown",
"Family": 1,
"Hand": "L",
"HealthCare": 2,
"Height": 70,
"Major": "BA",
"Marriage": 4,
"Party": "R",
"Pot": 5,
"Sex": "M",
"ShoeSize": 10.5,
"State": "CT",
"Student": 5,
"Weight": 150,
"_id": 5,
"_include": true
}, {
"Car": 1,
"Eyes": "Brown",
"Family": 2,
"Hand": "R",
"HealthCare": 4,
"Height": 66,
"Major": "ACC",
"Marriage": 2,
"Party": "R",
"Pot": 3,
"Sex": "M",
"ShoeSize": 8.25,
"State": "NJ",
"Student": 6,
"Weight": 125,
"_id": 6,
"_include": true
}, {
"Car": 0,
"Eyes": "Brown",
"Family": 1,
"Hand": "R",
"HealthCare": 2,
"Height": 67,
"Major": "BA",
"Marriage": 2,
"Party": "D",
"Pot": 4,
"Sex": "M",
"ShoeSize": 9,
"State": "NY",
"Student": 7,
"Weight": 155,
"_id": 7,
"_include": true
}, {
"Car": 1,
"Eyes": "Green",
"Family": 2,
"Hand": "L",
"HealthCare": 1,
"Height": 72,
"Major": "OIM",
"Marriage": 2,
"Party": "I",
"Pot": 4,
"Sex": "M",
"ShoeSize": 13,
"State": "PA",
"Student": 8,
"Weight": 260,
"_id": 8,
"_include": true
}, {
"Car": 1,
"Eyes": "Blue",
"Family": 2,
"Hand": "R",
"HealthCare": 3,
"Height": 72,
"Major": "BA",
"Marriage": 2,
"Party": "R",
"Pot": 4,
"Sex": "M",
"ShoeSize": 10.5,
"State": "NY",
"Student": 9,
"Weight": 155,
"_id": 9,
"_include": true
}, {
"Car": 1,
"Eyes": "Brown",
"Family": 2,
"Hand": "R",
"HealthCare": 3,
"Height": 71,
"Major": "ACC",
"Marriage": 2,
"Party": "D",
"Pot": 4,
"Sex": "M",
"ShoeSize": 12,
"State": "CT",
"Student": 10,
"Weight": 180,
"_id": 10,
"_include": true
}, {
"Car": 1,
"Eyes": "Blue",
"Family": 1,
"Hand": "R",
"HealthCare": 3,
"Height": 71,
"Major": "BA",
"Marriage": 4,
"Party": "R",
"Pot": 2,
"Sex": "M",
"ShoeSize": 11,
"State": "MD",
"Student": 11,
"Weight": 160,
"_id": 11,
"_include": true
}]
});
yadcf.init($("#dataset").DataTable(), [{
"column_number": 0,
"filter_type": "range_number_slider"
}, {
"column_number": 1,
"filter_type": "multi_select",
"select_type": "chosen"
}, {
"column_number": 2,
"filter_type": "range_number_slider"
}, {
"column_number": 3,
"filter_type": "multi_select",
"select_type": "chosen"
}, {
"column_number": 4,
"filter_type": "range_number_slider"
}, {
"column_number": 5,
"filter_type": "range_number_slider"
}, {
"column_number": 6,
"filter_type": "multi_select",
"select_type": "chosen"
}, {
"column_number": 7,
"filter_type": "range_number_slider"
}, {
"column_number": 8,
"filter_type": "multi_select",
"select_type": "chosen"
}, {
"column_number": 9,
"filter_type": "range_number_slider"
}, {
"column_number": 10,
"filter_type": "multi_select",
"select_type": "chosen"
}, {
"column_number": 11,
"filter_type": "range_number_slider"
}, {
"column_number": 12,
"filter_type": "multi_select",
"select_type": "chosen"
}, {
"column_number": 13,
"filter_type": "range_number_slider"
}, {
"column_number": 14,
"filter_type": "range_number_slider"
}]);
});
[1]: https://jsfiddle.net/mbaas/fbo0L88v/
Solved the issues with the Datatable (most notable I did not load the appropriate .css to support Bootstrap for the addons), I then had an issue with the pagelength-control not being wide enough to fully show the text for the "All"-Selection - that required some changes to the CSS which Allan will include in his downloads.
Just in case anyone else hits this:
div.dataTables_wrapper div.dataTables_length select {
width: auto;
}
Then I had an issue with vertical alignment of the controls surrounding the table - that needed a slightly more evolved dom-setting than I had:
"<'row'<'col-sm-12 col-md-6'B><'col-sm-12 col-md-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-12'i>>" +
"<'row'<'col-sm-12 col-md-5'l><'col-sm-12 col-md-7'p>>"
This should become significantly easier with one the next releases...
Even after sorting all that out, the yadcf-issue remained - but that seems to be a real bug, so I posted an issue on GitHub.

Fail to serialize JSON Objective-c

I have a problem. When I try to make test my json, it says that it is not valid. But when I test it with online services, it reads it well.
The code I use to test if json is valid is:
NSString* stringRes = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
[NSJSONSerialization isValidJSONObject:stringRes];
Where stringRes is son string in NSString format.(From data response)
JSON :
{
"response": [
9,
{
"id": 47,
"from_id": 211551056,
"to_id": -101815039,
"date": 1442585775,
"post_type": "post",
"text": "Кто на андроид кодит хоть немножк ? Хотя бы hello world ?",
"can_edit": 1,
"created_by": 211551056,
"can_delete": 1,
"post_source": {
"type": "api",
"platform": "iphone"
},
"comments": {
"count": 0,
"can_post": 1
},
"likes": {
"count": 0,
"user_likes": 0,
"can_like": 1,
"can_publish": 0
},
"reposts": {
"count": 0,
"user_reposted": 0
},
"online": 1,
"reply_count": 0
},
{
"id": 43,
"from_id": 217702824,
"to_id": -101815039,
"date": 1442555658,
"post_type": "post",
"text": "Учебник по географии",
"can_delete": 1,
"attachment": {
"type": "doc",
"doc": {
"did": 419802605,
"owner_id": 217702824,
"title": "11_geo_m_2012.pdf",
"size": 92318316,
"ext": "pdf",
"url": "http://vk.com/doc217702824_419802605?hash=5eb9bb9753a6f88e88&dl=fcadca27db5845a002&api=1",
"access_key": "8e4218746055687cc2"
}
},
"attachments": [
{
"type": "doc",
"doc": {
"did": 419802605,
"owner_id": 217702824,
"title": "11_geo_m_2012.pdf",
"size": 92318316,
"ext": "pdf",
"url": "http://vk.com/doc217702824_419802605?hash=5eb9bb9753a6f88e88&dl=fcadca27db5845a002&api=1",
"access_key": "8e4218746055687cc2"
}
}
],
"post_source": {
"type": "api",
"platform": "android"
},
"comments": {
"count": 0,
"can_post": 1
},
"likes": {
"count": 3,
"user_likes": 0,
"can_like": 1,
"can_publish": 0
},
"reposts": {
"count": 0,
"user_reposted": 0
},
"online": 0,
"reply_count": 0
},
{
"id": 37,
"from_id": 211551056,
"to_id": -101815039,
"date": 1442502437,
"post_type": "post",
"text": "У кого айфон, + в комменты",
"can_delete": 1,
"attachment": {
"type": "poll",
"poll": {
"poll_id": 195892301,
"question": "Удобно смотреть расписание ?(На сайте)"
}
},
"attachments": [
{
"type": "poll",
"poll": {
"poll_id": 195892301,
"question": "Удобно смотреть расписание ?(На сайте)"
}
}
],
"post_source": {
"type": "api",
"platform": "iphone"
},
"comments": {
"count": 5,
"can_post": 1
},
"likes": {
"count": 0,
"user_likes": 0,
"can_like": 1,
"can_publish": 0
},
"reposts": {
"count": 0,
"user_reposted": 0
},
"online": 1,
"reply_count": 5
},
{
"id": 36,
"from_id": 249011483,
"to_id": -101815039,
"date": 1442500757,
"post_type": "post",
"text": "Домашку выложить не забудьте 👌👆",
"can_delete": 1,
"post_source": {
"type": "api",
"platform": "iphone"
},
"comments": {
"count": 0,
"can_post": 1
},
"likes": {
"count": 1,
"user_likes": 0,
"can_like": 1,
"can_publish": 0
},
"reposts": {
"count": 0,
"user_reposted": 0
},
"online": 1,
"reply_count": 0
},
{
"id": 28,
"from_id": 211551056,
"to_id": -101815039,
"date": 1442306249,
"post_type": "post",
"text": "",
"can_delete": 1,
"media": {
"type": "photo",
"owner_id": -101815039,
"item_id": 381477357,
"thumb_src": "http://cs624425.vk.me/v624425056/49e35/_w_YDirrrQU.jpg"
},
"attachment": {
"type": "photo",
"photo": {
"pid": 381477357,
"aid": -8,
"owner_id": -101815039,
"user_id": 211551056,
"src": "http://cs624425.vk.me/v624425056/49e35/_w_YDirrrQU.jpg",
"src_big": "http://cs624425.vk.me/v624425056/49e36/439edT8aXks.jpg",
"src_small": "http://cs624425.vk.me/v624425056/49e34/uLxZj9yF1F4.jpg",
"src_xbig": "http://cs624425.vk.me/v624425056/49e37/nhvaG43cV-Y.jpg",
"src_xxbig": "http://cs624425.vk.me/v624425056/49e38/Ox54xM039hg.jpg",
"width": 960,
"height": 720,
"text": "",
"created": 1442306250,
"lat": 55.785025,
"long": 37.706605,
"post_id": 28,
"access_key": "454823aa95a2ee9fbc"
}
},
"attachments": [
{
"type": "photo",
"photo": {
"pid": 381477357,
"aid": -8,
"owner_id": -101815039,
"user_id": 211551056,
"src": "http://cs624425.vk.me/v624425056/49e35/_w_YDirrrQU.jpg",
"src_big": "http://cs624425.vk.me/v624425056/49e36/439edT8aXks.jpg",
"src_small": "http://cs624425.vk.me/v624425056/49e34/uLxZj9yF1F4.jpg",
"src_xbig": "http://cs624425.vk.me/v624425056/49e37/nhvaG43cV-Y.jpg",
"src_xxbig": "http://cs624425.vk.me/v624425056/49e38/Ox54xM039hg.jpg",
"width": 960,
"height": 720,
"text": "",
"created": 1442306250,
"lat": 55.785025,
"long": 37.706605,
"post_id": 28,
"access_key": "454823aa95a2ee9fbc"
}
}
],
"post_source": {
"type": "api",
"platform": "iphone"
},
"comments": {
"count": 0,
"can_post": 1
},
"likes": {
"count": 1,
"user_likes": 0,
"can_like": 1,
"can_publish": 0
},
"reposts": {
"count": 0,
"user_reposted": 0
},
"online": 1,
"reply_count": 0
},
{
"id": 27,
"from_id": 211551056,
"to_id": -101815039,
"date": 1442306164,
"post_type": "post",
"text": "",
"can_delete": 1,
"media": {
"type": "photo",
"owner_id": -101815039,
"item_id": 381477244,
"thumb_src": "http://cs624425.vk.me/v624425056/49e2c/kttj5pUpjTk.jpg"
},
"attachment": {
"type": "photo",
"photo": {
"pid": 381477244,
"aid": -8,
"owner_id": -101815039,
"user_id": 211551056,
"src": "http://cs624425.vk.me/v624425056/49e2c/kttj5pUpjTk.jpg",
"src_big": "http://cs624425.vk.me/v624425056/49e2d/ihg9szTvLew.jpg",
"src_small": "http://cs624425.vk.me/v624425056/49e2b/GpS0xwCa66c.jpg",
"src_xbig": "http://cs624425.vk.me/v624425056/49e2e/pe4tflJokqs.jpg",
"src_xxbig": "http://cs624425.vk.me/v624425056/49e2f/7vkU8nUyNxc.jpg",
"width": 960,
"height": 720,
"text": "",
"created": 1442306166,
"lat": 55.785083,
"long": 37.711116,
"post_id": 27,
"access_key": "cb01ac011f4abbc0af"
}
},
"attachments": [
{
"type": "photo",
"photo": {
"pid": 381477244,
"aid": -8,
"owner_id": -101815039,
"user_id": 211551056,
"src": "http://cs624425.vk.me/v624425056/49e2c/kttj5pUpjTk.jpg",
"src_big": "http://cs624425.vk.me/v624425056/49e2d/ihg9szTvLew.jpg",
"src_small": "http://cs624425.vk.me/v624425056/49e2b/GpS0xwCa66c.jpg",
"src_xbig": "http://cs624425.vk.me/v624425056/49e2e/pe4tflJokqs.jpg",
"src_xxbig": "http://cs624425.vk.me/v624425056/49e2f/7vkU8nUyNxc.jpg",
"width": 960,
"height": 720,
"text": "",
"created": 1442306166,
"lat": 55.785083,
"long": 37.711116,
"post_id": 27,
"access_key": "cb01ac011f4abbc0af"
}
}
],
"post_source": {
"type": "api",
"platform": "iphone"
},
"comments": {
"count": 0,
"can_post": 1
},
"likes": {
"count": 1,
"user_likes": 0,
"can_like": 1,
"can_publish": 0
},
"reposts": {
"count": 0,
"user_reposted": 0
},
"online": 1,
"reply_count": 0
},
{
"id": 16,
"from_id": 249011483,
"to_id": -101815039,
"date": 1442069345,
"post_type": "post",
"text": "Кто нибудь сделал алгебру ?",
"can_delete": 1,
"post_source": {
"type": "api",
"platform": "iphone"
},
"comments": {
"count": 6,
"can_post": 1
},
"likes": {
"count": 3,
"user_likes": 0,
"can_like": 1,
"can_publish": 0
},
"reposts": {
"count": 0,
"user_reposted": 0
},
"online": 1,
"reply_count": 6
},
{
"id": 9,
"from_id": 127082413,
"to_id": -101815039,
"date": 1441911418,
"post_type": "post",
"text": "Официальная информациия ,староста нашей группы Александр Кондор!",
"can_delete": 1,
"post_source": {
"type": "api",
"platform": "android"
},
"comments": {
"count": 6,
"can_post": 1
},
"likes": {
"count": 2,
"user_likes": 0,
"can_like": 1,
"can_publish": 0
},
"reposts": {
"count": 0,
"user_reposted": 0
},
"online": 1,
"reply_count": 6
},
{
"id": 1,
"from_id": -101815039,
"to_id": -101815039,
"date": 1441656588,
"post_type": "post",
"text": "",
"can_delete": 1,
"can_pin": 1,
"media": {
"type": "photo",
"owner_id": -101815039,
"item_id": 380592775,
"thumb_src": "http://cs629111.vk.me/v629111548/e99f/DcV1yHZK1fw.jpg"
},
"attachment": {
"type": "photo",
"photo": {
"pid": 380592775,
"aid": -6,
"owner_id": -101815039,
"user_id": 100,
"src": "http://cs629111.vk.me/v629111548/e99f/DcV1yHZK1fw.jpg",
"src_big": "http://cs629111.vk.me/v629111548/e9a0/Qf8q8PpH7Jg.jpg",
"src_small": "http://cs629111.vk.me/v629111548/e99e/2Jq8e-0SptQ.jpg",
"src_xbig": "http://cs629111.vk.me/v629111548/e9a1/Uha0MvOoVCU.jpg",
"src_xxbig": "http://cs629111.vk.me/v629111548/e9a2/v8hqUldA6Kk.jpg",
"width": 730,
"height": 1024,
"text": "",
"created": 1441656588,
"post_id": 1
}
},
"attachments": [
{
"type": "photo",
"photo": {
"pid": 380592775,
"aid": -6,
"owner_id": -101815039,
"user_id": 100,
"src": "http://cs629111.vk.me/v629111548/e99f/DcV1yHZK1fw.jpg",
"src_big": "http://cs629111.vk.me/v629111548/e9a0/Qf8q8PpH7Jg.jpg",
"src_small": "http://cs629111.vk.me/v629111548/e99e/2Jq8e-0SptQ.jpg",
"src_xbig": "http://cs629111.vk.me/v629111548/e9a1/Uha0MvOoVCU.jpg",
"src_xxbig": "http://cs629111.vk.me/v629111548/e9a2/v8hqUldA6Kk.jpg",
"width": 730,
"height": 1024,
"text": "",
"created": 1441656588,
"post_id": 1
}
}
],
"post_source": {
"type": "api",
"platform": "android",
"data": "profile_photo"
},
"comments": {
"count": 0,
"can_post": 1
},
"likes": {
"count": 0,
"user_likes": 0,
"can_like": 1,
"can_publish": 0
},
"reposts": {
"count": 0,
"user_reposted": 0
},
"online": 1,
"reply_count": 0
}
]
}
UPD: Solved by using
NSData* data = [stringRes dataUsingEncoding:NSUTF8StringEncoding];
isValidJSONObject tests if a JSON object (a NSDictionary or NSArray) can be successfully converted to JSON data.
It is not for testing if an NSData object contains valid JSON data. To test for valid JSON data you just call
[NSJSONSerialization JSONObjectWithData:data ...]
and check if the return value is nil or not.

JSON Objective-c - Objects and Arrays Combination

My JSON url is http://api.kivaws.org/v1/loans/search.json?status=fundraising
My Objective- code displays page_size : 20 using the following code
NSData *allCourseData=[[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:#"http://api.kivaws.org/v1/loans/search.json?status=fundraising"]];
NSError *error;
NSMutableDictionary *JsonObject = [NSJSONSerialization
JSONObjectWithData:allCourseData options:NSJSONReadingMutableContainers
error:&error];
//NSLog(#"json object is: - %#", JsonObject);
//Print Page size
NSLog(#"Page size is %#", [[JsonObject objectForKey:#"paging"] objectForKey:#"page_size"]);
My problem is how do i loop to Loans array to display the following
Example it will display name, display ALL languages, status so output will look like
============================
Name : "Maria Luisa"
languages: es,en
status : "fundraising"
sector : "Retail"
location
country_code : "NI"
Name : "Florence"
languages: en
status : "fundraising"
sector : "Retail"
location
country_code : "KE"
MyJSON Feed
{
"paging": {
"page": 1,
"total": 7279,
"page_size": 20,
"pages": 364
},
"loans": [
{
"id": 941933,
"name": "Maria Luisa",
"description": {
"languages": [
"es",
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1969857,
"template_id": 1
},
"activity": "General Store",
"sector": "Retail",
"use": "to buy rice, chicken, sausages, corn, beans, and sugar.",
"location": {
"country_code": "NI",
"country": "Nicaragua",
"town": "Esteli",
"geo": {
"level": "town",
"pairs": "13.166667 -86.333333",
"type": "point"
}
},
"partner_id": 176,
"posted_date": "2015-09-04T09:20:02Z",
"planned_expiration_date": "2015-10-04T09:20:02Z",
"loan_amount": 600,
"borrower_count": 1,
"lender_count": 0,
"bonus_credit_eligibility": true,
"tags": []
},
{
"id": 942181,
"name": "Florence",
"description": {
"languages": [
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1970181,
"template_id": 1
},
"activity": "Retail",
"sector": "Retail",
"use": "to buy more stocks of maize.",
"location": {
"country_code": "KE",
"country": "Kenya",
"town": "Bondo",
"geo": {
"level": "town",
"pairs": "1 38",
"type": "point"
}
},
"partner_id": 138,
"posted_date": "2015-09-04T09:10:08Z",
"planned_expiration_date": "2015-10-04T09:10:08Z",
"loan_amount": 200,
"borrower_count": 1,
"lender_count": 0,
"bonus_credit_eligibility": true,
"tags": []
},
{
"id": 942146,
"name": "Naziha",
"description": {
"languages": [
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1970129,
"template_id": 1
},
"activity": "Fruits & Vegetables",
"sector": "Food",
"use": "to increase her merchandise and diversify the products in her shop.",
"location": {
"country_code": "LB",
"country": "Lebanon",
"town": "Ain Al Helwi",
"geo": {
"level": "town",
"pairs": "33.833333 35.833333",
"type": "point"
}
},
"partner_id": 77,
"posted_date": "2015-09-04T09:10:02Z",
"planned_expiration_date": "2015-10-04T09:10:02Z",
"loan_amount": 2500,
"borrower_count": 1,
"lender_count": 0,
"bonus_credit_eligibility": true,
"tags": []
},
{
"id": 942180,
"name": "Sokean's Group",
"description": {
"languages": [
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1970180,
"template_id": 1
},
"activity": "Home Appliances",
"sector": "Personal Use",
"themes": [
"Water and Sanitation"
],
"use": "to buy a water filter to provide safe drinking water for her family.",
"location": {
"country_code": "KH",
"country": "Cambodia",
"town": "Kandal",
"geo": {
"level": "town",
"pairs": "13 105",
"type": "point"
}
},
"partner_id": 311,
"posted_date": "2015-09-04T09:00:05Z",
"planned_expiration_date": "2015-10-04T09:00:05Z",
"loan_amount": 100,
"borrower_count": 2,
"lender_count": 0,
"bonus_credit_eligibility": false,
"tags": [
{
"name": "volunteer_like"
}
]
},
{
"id": 941931,
"name": "Lucia Ingrid",
"description": {
"languages": [
"es",
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1969852,
"template_id": 1
},
"activity": "Personal Housing Expenses",
"sector": "Housing",
"themes": [
"Conflict Zones"
],
"use": "to invest in: electric wires, a fuse box, sockets, and labor to install electricity in her home.",
"location": {
"country_code": "SV",
"country": "El Salvador",
"geo": {
"level": "country",
"pairs": "13.833333 -88.916667",
"type": "point"
}
},
"partner_id": 81,
"posted_date": "2015-09-04T09:00:03Z",
"planned_expiration_date": "2015-10-04T09:00:03Z",
"loan_amount": 500,
"borrower_count": 1,
"lender_count": 0,
"bonus_credit_eligibility": true,
"tags": []
},
{
"id": 941930,
"name": "La Manzanita Group",
"description": {
"languages": [
"es",
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1969849,
"template_id": 1
},
"activity": "Fruits & Vegetables",
"sector": "Food",
"use": "to invest in buying papayas and nance berries in bulk.",
"location": {
"country_code": "NI",
"country": "Nicaragua",
"town": "Masaya",
"geo": {
"level": "town",
"pairs": "11.966667 -86.1",
"type": "point"
}
},
"partner_id": 120,
"posted_date": "2015-09-04T08:50:02Z",
"planned_expiration_date": "2015-10-04T08:50:02Z",
"loan_amount": 450,
"borrower_count": 3,
"lender_count": 0,
"bonus_credit_eligibility": true,
"tags": []
},
{
"id": 941926,
"name": "Manuel",
"description": {
"languages": [
"es",
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1969843,
"template_id": 1
},
"activity": "Property",
"sector": "Housing",
"use": "to buy two acres of land.",
"location": {
"country_code": "GT",
"country": "Guatemala",
"town": "Solola",
"geo": {
"level": "town",
"pairs": "14.666667 -91.25",
"type": "point"
}
},
"partner_id": 246,
"posted_date": "2015-09-04T08:10:02Z",
"planned_expiration_date": "2015-10-04T08:10:02Z",
"loan_amount": 800,
"borrower_count": 1,
"lender_count": 0,
"bonus_credit_eligibility": true,
"tags": [
{
"name": "volunteer_like"
}
]
},
{
"id": 942158,
"name": "Tahira",
"description": {
"languages": [
"en"
]
},
"status": "fundraising",
"funded_amount": 150,
"basket_amount": 0,
"image": {
"id": 1969161,
"template_id": 1
},
"activity": "Sewing",
"sector": "Services",
"themes": [
"Underfunded Areas"
],
"use": "buy a new sewing machine for her clothes sewing center.",
"location": {
"country_code": "PK",
"country": "Pakistan",
"town": "Multan",
"geo": {
"level": "town",
"pairs": "30.195556 71.475278",
"type": "point"
}
},
"partner_id": 247,
"posted_date": "2015-09-04T07:00:05Z",
"planned_expiration_date": "2015-10-04T07:00:05Z",
"loan_amount": 400,
"borrower_count": 1,
"lender_count": 5,
"bonus_credit_eligibility": false,
"tags": []
},
{
"id": 942166,
"name": "Sareoun's Group",
"description": {
"languages": [
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1970161,
"template_id": 1
},
"activity": "Home Appliances",
"sector": "Personal Use",
"themes": [
"Water and Sanitation"
],
"use": "to buy a water filter to provide safe drinking water for their family.\t.",
"location": {
"country_code": "KH",
"country": "Cambodia",
"town": "Kandal",
"geo": {
"level": "town",
"pairs": "13 105",
"type": "point"
}
},
"partner_id": 311,
"posted_date": "2015-09-04T07:00:05Z",
"planned_expiration_date": "2015-10-04T07:00:05Z",
"loan_amount": 225,
"borrower_count": 5,
"lender_count": 0,
"bonus_credit_eligibility": false,
"tags": []
},
{
"id": 942156,
"name": "Aiza",
"description": {
"languages": [
"en"
]
},
"status": "fundraising",
"funded_amount": 75,
"basket_amount": 0,
"image": {
"id": 1970147,
"template_id": 1
},
"activity": "Farming",
"sector": "Agriculture",
"use": "to buy fertilizers and other farm supplies",
"location": {
"country_code": "PH",
"country": "Philippines",
"town": "Kalibo, Aklan",
"geo": {
"level": "town",
"pairs": "13 122",
"type": "point"
}
},
"partner_id": 145,
"posted_date": "2015-09-04T07:00:03Z",
"planned_expiration_date": "2015-10-04T07:00:03Z",
"loan_amount": 225,
"borrower_count": 1,
"lender_count": 2,
"bonus_credit_eligibility": true,
"tags": []
},
{
"id": 942160,
"name": "Magu Group",
"description": {
"languages": [
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1970122,
"template_id": 1
},
"activity": "Used Clothing",
"sector": "Clothing",
"use": "to buy fast moving second hand clothes to meet her customer requirement.",
"location": {
"country_code": "TZ",
"country": "Tanzania",
"town": "Dar es Salaam",
"geo": {
"level": "town",
"pairs": "-6.8 39.283333",
"type": "point"
}
},
"partner_id": 87,
"posted_date": "2015-09-04T07:00:02Z",
"planned_expiration_date": "2015-10-04T07:00:02Z",
"loan_amount": 525,
"borrower_count": 2,
"lender_count": 0,
"bonus_credit_eligibility": true,
"tags": []
},
{
"id": 942142,
"name": "Mwanamiraji",
"description": {
"languages": [
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1970130,
"template_id": 1
},
"activity": "Food Stall",
"sector": "Food",
"use": "to purchase a stock of tomatoes, onions, mangoes and green vegetables for resale",
"location": {
"country_code": "KE",
"country": "Kenya",
"town": "Tiribe",
"geo": {
"level": "town",
"pairs": "1 38",
"type": "point"
}
},
"partner_id": 164,
"posted_date": "2015-09-04T06:30:04Z",
"planned_expiration_date": "2015-10-04T06:30:04Z",
"loan_amount": 200,
"borrower_count": 1,
"lender_count": 0,
"bonus_credit_eligibility": true,
"tags": []
},
{
"id": 940065,
"name": "Tubogorane Group",
"description": {
"languages": [
"fr",
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1967147,
"template_id": 1
},
"activity": "Food",
"sector": "Food",
"themes": [
"Conflict Zones"
],
"use": "to increase his working capital and buy a large quantity of fruit and cheese for sale.",
"location": {
"country_code": "BI",
"country": "Burundi",
"town": "Bujumbura",
"geo": {
"level": "town",
"pairs": "-3.5 30",
"type": "point"
}
},
"partner_id": 162,
"posted_date": "2015-09-04T06:20:05Z",
"planned_expiration_date": "2015-10-04T06:20:05Z",
"loan_amount": 3050,
"borrower_count": 19,
"lender_count": 0,
"bonus_credit_eligibility": false,
"tags": []
},
{
"id": 940076,
"name": "Wend Loiim Taore 2 Group",
"description": {
"languages": [
"fr",
"en"
]
},
"status": "fundraising",
"funded_amount": 50,
"basket_amount": 0,
"image": {
"id": 1967173,
"template_id": 1
},
"activity": "Clothing Sales",
"sector": "Clothing",
"use": "to buy pagnes (traditional, wrap-around clothing) and soap for sale.",
"location": {
"country_code": "BF",
"country": "Burkina Faso",
"town": "Ouagadougou Boulmiougou",
"geo": {
"level": "town",
"pairs": "13 -2",
"type": "point"
}
},
"partner_id": 398,
"posted_date": "2015-09-04T06:20:05Z",
"planned_expiration_date": "2015-10-04T06:20:05Z",
"loan_amount": 1850,
"borrower_count": 5,
"lender_count": 2,
"bonus_credit_eligibility": false,
"tags": []
},
{
"id": 942145,
"name": "Adham",
"description": {
"languages": [
"en"
]
},
"status": "fundraising",
"funded_amount": 25,
"basket_amount": 0,
"image": {
"id": 1970127,
"template_id": 1
},
"activity": "Barber Shop",
"sector": "Services",
"use": "to buy new salon equipment.",
"location": {
"country_code": "PS",
"country": "Palestine",
"town": "Bethlehem",
"geo": {
"level": "town",
"pairs": "31.92157 35.203285",
"type": "point"
}
},
"partner_id": 289,
"posted_date": "2015-09-04T06:10:04Z",
"planned_expiration_date": "2015-10-04T06:10:04Z",
"loan_amount": 3000,
"borrower_count": 1,
"lender_count": 2,
"bonus_credit_eligibility": false,
"tags": [
{
"name": "user_favorite"
}
]
},
{
"id": 941929,
"name": "Silvia Yesenia",
"description": {
"languages": [
"es",
"en"
]
},
"status": "fundraising",
"funded_amount": 0,
"basket_amount": 0,
"image": {
"id": 1969848,
"template_id": 1
},
"activity": "Retail",
"sector": "Retail",
"themes": [
"Conflict Zones"
],
"use": " to buy vegetables, legumes, staple grains and meat, amongst other items, to offer a better service to her customers",
"location": {
"country_code": "SV",
"country": "El Salvador",
"geo": {
"level": "country",
"pairs": "13.833333 -88.916667",
"type": "point"
}
},
"partner_id": 81,
"posted_date": "2015-09-04T06:10:03Z",
"planned_expiration_date": "2015-10-04T06:10:03Z",
"loan_amount": 500,
"borrower_count": 1,
"lender_count": 0,
"bonus_credit_eligibility": true,
"tags": []
}
]
}
Well the loans array is in the top-level JSON object, so:
NSArray *loans = jsonObject[#"loans"];
for (NSDictionary *loan in loans) {
NSNumber *ident = loan[#"id"];
NSString *name = loan[#"name"];
NSDictionary *description = loan[#"description"];
NSDictionary *location = loan[#"location"];
NSString *country = location[#"country"];
// etc.
}
NSData *allCourseData=[[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:#"http://api.kivaws.org/v1/loans/search.json?status=fundraising"]];
NSError *error;
NSMutableDictionary *JsonObject = [NSJSONSerialization
JSONObjectWithData:allCourseData options:NSJSONReadingMutableContainers
error:&error];
// Get loans array from JsonObject
NSArray *loanJsonObject = JsonObject[#"loans"];
// Create a new loans array for store the new items
NSMutableArray *newLoans = [NSMutableArray array];
// Loop loanJsonObject to get items and create new ones
// for then store them in the new loans array
for (NSDictionary *loan in loanJsonObject) {
NSDictionary *newLoan = #{
#"name": loan[#"name"],
#"status": loan[#"status"],
#"sector": loan[#"sector"],
#"languages": loan[#"description"][#"languages"],
#"location": #{
#"country": loan[#"location"][#"country"],
#"geo": #{
#"pairs": loan[#"location"][#"geo"][#"pairs"]
}
}
};
[newLoans addObject:newLoan];
}
// the new loans
NSLog(#"newLoans: %#", newLoans);
well your loans object is an array of dictionaries.
By [JsonObject objectForKey:#"loans"] you are getting an array.
then you need to iterate for desired result.
NSArray *arrloans = [JsonObject objectForKey:#"loans"];
for (NSDictionary *dicloans in arrloans) {
NSString *name = [JsonObject objectForKey:#"name"];
NSString *countryCode = [[JsonObject objectForKey:#"location"]objectForKey:#"country_code"]; }