Push array of object to JSON in angular - angularjs

I do have a JSON object shown below
[
{
"directories": [
{
"type": "folder",
"name": "Real Estate",
"order": "1",
"delete": "false",
"canModify": "true"
},
{
"type": "folder",
"name": "ABC",
"order": "8",
"delete": "false",
"canModify": "true"
},
{
"type": "folder",
"name": "Legal",
"order": "2",
"delete": "false",
"canModify": "false",
"directories": [
{
"type": "subfolder",
"name": "Lease",
"order": "9",
"delete": "false",
"canModify": "false"
}
]
},
{
"type": "folder",
"name": "Construction",
"order": "4",
"delete": "false",
"canModify": "true"
}
]
}
]
I have an array of object which i need to push inside the object having "name:Construction".
I Tried with following code
var folderObj = {
"name": "",
"canModify":'true',
"type":'folder',
"delete":'false',
"order": $scope.directories.length + 1
}
$scope.directories.push(folderObj);
The actual output what i need is to push the object inside a parent folder
[
{
"directories": [
{
"type": "folder",
"name": "Real Estate",
"order": "1",
"delete": "false",
"canModify": "true"
},
{
"type": "folder",
"name": "ABC",
"order": "8",
"delete": "false",
"canModify": "true"
},
{
"type": "folder",
"name": "Legal",
"order": "2",
"delete": "false",
"canModify": "false",
"directories": [
{
"type": "subfolder",
"name": "Lease",
"order": "9",
"delete": "false",
"canModify": "false"
}
]
},
{
"type": "folder",
"name": "Construction",
"order": "4",
"delete": "false",
"canModify": "true",
"directories": [
{
"type": "subfolder",
"name": "NewFolder",
"order": "10",
"delete": "false",
"canModify": "false"
}
]
}
]
}
]
As i am new to angular i was not able to figure it out how to push the object, So any help appreciated.

You need to write a recursive function. Try following
let arr = [{"directories":[{"type":"folder","name":"Real Estate","order":"1","delete":"false","canModify":"true"},{"type":"folder","name":"ABC","order":"8","delete":"false","canModify":"true"},{"type":"folder","name":"Legal","order":"2","delete":"false","canModify":"false","directories":[{"type":"subfolder","name":"Lease","order":"9","delete":"false","canModify":"false"}]},{"type":"folder","name":"Construction","order":"4","delete":"false","canModify":"true"}]}];
let obj = {"type":"subfolder","name":"NewFolder","order":"10","delete":"false","canModify":"false"};
let label = "Construction";
/* Function takes 3 inputs
* a - arr containing objects
* l - label - unique identifier of the match
* o - object that needs to be added */
function addObjectToTree(a, l, o) {
// Iterate over arr
for (let i = 0; i < a.length; i++) {
let p = a[i]; // get the object
if(p.name === l) { // if there is a match add to directories
p.directories = (p.directories || []).concat([o]);
return true;
} else if(p.directories) { // else check if there are sub-folders
// If there was a match in sub folders break the loop
if(addObjectToTree(p.directories, l, o)) break;
}
}
}
addObjectToTree(arr, label, obj);
console.log(arr);

Related

Azure Data Factory - How to transform object with dynamic keys to array in a data flow?

After spending many hours of reading the documentation, following some tutorials and trial & error, i just can't figure it out; how can I transform the following complex object with key objects to an array using a data flow in Azure Data Factory?
Input
{
"headers": {
"Content-Length": 1234
},
"body": {
"00b50a39-8591-3db3-88f7-635e2ec5c65a": {
"id": "00b50a39-8591-3db3-88f7-635e2ec5c65a",
"name": "Example 1",
"date": "2023-02-09"
},
"0c206312-2348-391b-99f0-261323a94d95": {
"id": "0c206312-2348-391b-99f0-261323a94d95",
"name": "Example 2",
"date": "2023-02-09"
},
"0c82d1e4-a897-32f2-88db-6830a21b0a43": {
"id": "00b50a39-8591-3db3-88f7-635e2ec5c65a",
"name": "Example 3",
"date": "2023-02-09"
},
}
}
Expected output
[
{
"id": "00b50a39-8591-3db3-88f7-635e2ec5c65a",
"name": "Example 1",
"date": "2023-02-09"
},
{
"id": "0c206312-2348-391b-99f0-261323a94d95",
"name": "Example 2",
"date": "2023-02-09"
},
{
"id": "00b50a39-8591-3db3-88f7-635e2ec5c65a",
"name": "Example 3",
"date": "2023-02-09"
}
]
AFAIK, Your JSON keys are dynamic. So, getting the desired result using dataflow might not be possible.
In this case, you can try the below approach as a workaround. This will work only if all of your key's length is same.
This is my Pipeline:
First I have used a lookup activity to get the JSON file and converted the lookup output to a string and stored in a variable using below expression.
#substring(string(activity('Lookup1').output.value[0].body),2,sub(length(string(activity('Lookup1').output.value[0].body)),4)).
Then I have used split on that String variable with '},"' and stored in an array variable using below expression.
#split(variables('res_str'),'},"')
It will give the array like below.
Give that array to a ForEach and inside ForEach use an append variable activity to store the keys into an array with below expression.
#take(item(), 36)
Now, I got the list of keys in an array, after the above ForEach use another ForEach activity to get the desired array of objects. Use append variable actvity inside ForEach and give the below expression for it.
#activity('Lookup1').output.value[0].body[item()]
Result array after ForEach will be:
If you want to store the above JSON into a file, you need to use OPENJSON from SQL. This is because copy activity additonal column only supports string type not an array type.
Use a SQL dataset on copy activity source and give the below SQL script in the query.
DECLARE #json NVARCHAR(MAX)
SET #json =
N'#{variables('json_arr')}'
SELECT * FROM
OPENJSON ( #json )
WITH (
id varchar(200) '$.id' ,
name varchar(32) '$.name',
date varchar(32) '$.date'
)
In Sink, give a JSON dataset and select Array of Objects as File pattern.
Execute the pipeline and you will get the above array inside a file.
This is my Pipeline JSON:
{
"name": "pipeline1",
"properties": {
"activities": [
{
"name": "Lookup1",
"type": "Lookup",
"dependsOn": [],
"policy": {
"timeout": "0.12:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"userProperties": [],
"typeProperties": {
"source": {
"type": "JsonSource",
"storeSettings": {
"type": "AzureBlobFSReadSettings",
"recursive": true,
"enablePartitionDiscovery": false
},
"formatSettings": {
"type": "JsonReadSettings"
}
},
"dataset": {
"referenceName": "Json1",
"type": "DatasetReference"
},
"firstRowOnly": false
}
},
{
"name": "Lookup output to Str",
"description": "",
"type": "SetVariable",
"dependsOn": [
{
"activity": "Lookup1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"variableName": "res_str",
"value": {
"value": "#substring(string(activity('Lookup1').output.value[0].body),2,sub(length(string(activity('Lookup1').output.value[0].body)),4))",
"type": "Expression"
}
}
},
{
"name": "Split Str to array",
"type": "SetVariable",
"dependsOn": [
{
"activity": "Lookup output to Str",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"variableName": "split_arr",
"value": {
"value": "#split(variables('res_str'),'},\"')",
"type": "Expression"
}
}
},
{
"name": "build keys array using split array",
"type": "ForEach",
"dependsOn": [
{
"activity": "Split Str to array",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"items": {
"value": "#variables('split_arr')",
"type": "Expression"
},
"isSequential": true,
"activities": [
{
"name": "take first 36 chars of every item",
"type": "AppendVariable",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"variableName": "keys_array",
"value": {
"value": "#take(item(), 36)",
"type": "Expression"
}
}
}
]
}
},
{
"name": "build final array using keys array",
"type": "ForEach",
"dependsOn": [
{
"activity": "build keys array using split array",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"items": {
"value": "#variables('keys_array')",
"type": "Expression"
},
"isSequential": true,
"activities": [
{
"name": "Append variable1",
"description": "append every object to array",
"type": "AppendVariable",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"variableName": "json_arr",
"value": {
"value": "#activity('Lookup1').output.value[0].body[item()]",
"type": "Expression"
}
}
}
]
}
},
{
"name": "Just for Res show",
"type": "SetVariable",
"dependsOn": [
{
"activity": "build final array using keys array",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"variableName": "final_res_show",
"value": {
"value": "#variables('json_arr')",
"type": "Expression"
}
}
},
{
"name": "Copy data1",
"type": "Copy",
"dependsOn": [
{
"activity": "Just for Res show",
"dependencyConditions": [
"Succeeded"
]
}
],
"policy": {
"timeout": "0.12:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"userProperties": [],
"typeProperties": {
"source": {
"type": "AzureSqlSource",
"sqlReaderQuery": "DECLARE #json NVARCHAR(MAX)\nSET #json = \n N'#{variables('json_arr')}' \n \nSELECT * FROM \n OPENJSON ( #json ) \nWITH ( \n id varchar(200) '$.id' , \n name varchar(32) '$.name', \n date varchar(32) '$.date'\n )",
"queryTimeout": "02:00:00",
"partitionOption": "None"
},
"sink": {
"type": "JsonSink",
"storeSettings": {
"type": "AzureBlobFSWriteSettings"
},
"formatSettings": {
"type": "JsonWriteSettings",
"filePattern": "arrayOfObjects"
}
},
"enableStaging": false
},
"inputs": [
{
"referenceName": "AzureSqlTable1",
"type": "DatasetReference"
}
],
"outputs": [
{
"referenceName": "Target_JSON",
"type": "DatasetReference"
}
]
}
],
"variables": {
"res_str": {
"type": "String"
},
"split_arr": {
"type": "Array"
},
"keys_array": {
"type": "Array"
},
"final_res_show": {
"type": "Array"
},
"json_arr": {
"type": "Array"
}
},
"annotations": []
}
}
Result file:

Removing and printing name/value pair from json using jolt

I want to remove a name/value pair from inside a json array and print it outside. I started by trying this and then expanding the whole request to be a json array. The solution mentioned above does not seem to be working.
Input :
[
{
"createdBy": "Admin",
"createdDate": "2022-09-08",
"modifiedBy": "Admin",
"attrs": [
{
"name": "Type",
"value": "Postpaid"
},
{
"name": "subscriber",
"value": "Paid"
},
{
"name": "Details",
"value": {
"createdDate": "today",
"description": "offer",
"id": null
}
}
],
"relatedInfo": [
{
"type": "Number",
"name": "000000"
},
{
"type": "Type",
"name": "Post"
}
]
},
{
"createdBy": "Admin",
"createdDate": "2022-09-08",
"modifiedBy": "Admin",
"attrs": [
{
"name": "Type",
"value": "Postpaid"
},
{
"name": "subscriber",
"value": "Paid"
},
{
"name": "Details",
"value": {
"createdDate": "today",
"description": "offer",
"id": null
}
}
],
"relatedInfo": [
{
"type": "Number",
"name": "000000"
},
{
"type": "Type",
"name": "Post"
}
]
}
]
Desired Output :
[
{
"createdBy": "Admin",
"createdDate": "2022-09-08",
"modifiedBy": "Admin",
"attrs": [
{
"name": "Type",
"value": "Postpaid"
},
{
"name": "subscriber",
"value": "Paid"
}
],
"Details": {
"createdDate": "today",
"description": "offer",
"id": null
},
"relatedInfo": [
{
"type": "Number",
"name": "000000"
},
{
"type": "Type",
"name": "Post"
}
]
},
{
"createdBy": "Admin",
"createdDate": "2022-09-08",
"modifiedBy": "Admin",
"attrs": [
{
"name": "Type",
"value": "Postpaid"
},
{
"name": "subscriber",
"value": "Paid"
}
],
"Details": {
"createdDate": "today",
"description": "offer",
"id": null
},
"relatedInfo": [
{
"type": "Number",
"name": "000000"
},
{
"type": "Type",
"name": "Post"
}
]
}
]
Current Jolt spec:
[
{
"operation": "shift",
"spec": {
"*": "[&]",
"attrs": {
"*": {
"name": {
"*": { "#2": "&4" },
"Details": {
"#(2,value)": "&1"
}
}
}
}
}
}
]
I can't seem to figure out how the jolt spec would change in case of the array
So far so good, just need to combine the attributes at a common node. To do this, I've used the identifiers [&1] and [&5] in order to reach the level of the outermost index within the tree such as
[
{
"operation": "shift",
"spec": {
"*": {
"*": "[&1].&",
"attrs": {
"*": {
"name": {
"*": {
"#2": "[&5].&4"
},
"Details": {
"#(2,value)": "[&5].&1"
}
}
}
}
}
}
}
]

Copy a top level element into each element of an array using Jolt

I am working on to push down the top level field into each element of the array inside it.
I want to push 'sourceEntity' into the each element of 'supportedCountries' array and 'supportedCurrencies' Array
input JSON:
{
"description": "SUPPORTED_COUNTRY_CURRENCY",
"id": "20190902025202944",
"type": "devuae-SUPPORTED_COUNTRY_CURRENCY",
"sourceEntity": "EBI",
"sourceChannel": "COR",
"timestamp": "1567421549887",
"supportedCountries": [
{
"code": "IN",
"name": "India",
"supportedCurrencies": [
{
"code": "JOD",
"name": "JORDANIAN DINAR",
"isLocal": true
}
]
}
]
}
Expected OUTPUT:
{
"description": "SUPPORTED_COUNTRY_CURRENCY",
"id": "20190902025202944",
"type": "devuae-SUPPORTED_COUNTRY_CURRENCY",
"sourceEntity": "EBI",
"sourceChannel": "COR",
"timestamp": "1567421549887",
"supportedCountries": [
{
"EntityID": "EBI",
"code": "IN",
"name": "India",
"supportedCurrencies": [
{
"UnitID": "EBI",
"code": "JOD",
"name": "JORDANIAN DINAR",
"isLocal": true
}
]
}
]
}
Help me to solve this
May be this might help,
[
{
"operation": "shift",
"spec": {
"description": "description",
"id": "id",
"type": "type",
"sourceEntity": "sourceEntity",
"sourceChannel": "sourceChannel",
"timestamp": "timestamp",
"supportedCountries": {
"*": {
//Shifting sourceEntity from the level 1
"#(2,sourceEntity)": "supportedCountries[&1].EntityID",
"code": "supportedCountries[&1].code",
"name": "supportedCountries[&1].name",
"supportedCurrencies": {
"*": {
//Shifting sourceEntity from the level 1
"#(4,sourceEntity)": "supportedCountries[&1].supportedCurrencies[&1].UnitID",
"code": "supportedCountries[&1].supportedCurrencies[&1].code",
"name": "supportedCountries[&1].supportedCurrencies[&1].name",
"isLocal": "supportedCountries[&1].supportedCurrencies[&1].isLocal"
}
}
}
}
}
}
]

Elastic - JSON Array nested in Array

I have to index a json to Elastic which look like the below format. My problem is that the key "variable" is array that contains json objects (I thought about "nested" datatype of Elastic) but some of those objects it's possible to contain nested json arrays inside them. (see variable CUSTOMERS).
POST /example_data/data {
"process_name": "TEST_PROCESS",
"process_version ": 0,
"process_id": "1111",
"activity_id": "111",
"name": "update_data",
"username": "testUser",
"datetime": "2018-01-01 10:00:00",
"variables": [{
"name": "ΒΑΝΚ",
"data_type": "STRING",
"value": "EUROBANK"
},{
"name": "CITY",
"data_type": "STRING",
"value": "LONDON"
}, {
"name": "CUSTOMERS",
"data_type": "ENTITY",
"value": [{
"variables": [{
"name": "CUSTOMER_NAME",
"data_type": "STRING",
"value": "JOHN"
}, {
"name": " CUSTOMER_CITY",
"data_type": "STRING",
"value": "LONDON"
}
]
}
]
}, {
"name": "CUSTOMERS",
"data_type": "ENTITY",
"value": [{
"variables": [{
"name": "CUSTOMER_NAME",
"data_type": "STRING",
"value": "ΑΘΗΝΑ"
}, {
"name": " CUSTOMER_CITY ",
"data_type": "STRING",
"value": "LIVERPOOL"
}, {
"name": " CUSTOMER_NUMBER",
"data_type": "STRING",
"value": "1234567890"
}
]
}
]
}
] }
When I'm trying to index it I get the following error
{ "error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [variables.value] with an object mapping [variables.value]"
}
],
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [variables.value] with an object mapping [variables.value]" }, "status": 400 }
Mapping
{ "example_data": {
"mappings": {
"data": {
"properties": {
"activity_id": {
"type": "text"
},
"name": {
"type": "text"
},
"process_name": {
"type": "text"
},
"process_version": {
"type": "integer"
}
"process_id": {
"type": "text"
},
"datetime": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"username": {
"type": "text",
"analyzer": "greek"
},
"variables": {
"type": "nested",
"properties": {
"data_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"value": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}}}
When I remove the variable CUSTOMERS that contains the array, then It works properly because there are only json objects.
Is there a way to handle that? Thanks in advance

Use a for-in loop to get data from a JSON object which is not an array

I'm trying to loop through the results of a JSON response and get the title of each article, however my hosting company mentioned the returned object is not an array, so I can't loop through the articles.
Currently it gives me an undefined on the length of the amount of articles.
How can I loop through the articles and get their titles?
I tried everything below, and finally read somewhere I could use a for-in loop.
So I was checking out this example here: http://www.w3schools.com/js/tryit.asp?filename=tryjs_object_for_in
However, I have no idea how to apply this loop on my data to get just the articles and then loop through these and get their properties.
JSON RESPONSE
{
"blog": {
"id": "1464",
"comments": true,
"url": "blogs\/magazine",
"rss": "blogs\/magazine.rss",
"title": "Taj Magazine",
"articles": {
"3748": {
"id": 3748,
"image": 7442452,
"url": "blogs\/magazine\/foodies-walhalla-2",
"title": "Foodies Walhalla 2",
"author": "",
"author_url": false,
"summary": "dit is de samenvatting tekst",
"content": "dit is het hele artikel",
"date": "2013-11-13 13:54:00",
"comments": [],
"comments_count": 0,
"tags": {
"foodies-walhalla": {
"id": "9794",
"url": "blogs\/magazine\/tagged\/foodies-walhalla",
"title": "Foodies Walhalla",
"count": "2"
},
"magazine": {
"id": "9744",
"url": "blogs\/magazine\/tagged\/magazine",
"title": "magazine",
"count": "6"
}
}
},
"3747": {
"id": 3747,
"image": 7442441,
"url": "blogs\/magazine\/foodies-walhalla-1",
"title": "Foodies Walhalla 1",
"author": "",
"author_url": false,
"summary": "f df gdsfg",
"content": "dsfgsdfgdf sdfg",
"date": "2013-11-13 11:22:00",
"comments": [],
"comments_count": 0,
"tags": {
"foodies-walhalla": {
"id": "9794",
"url": "blogs\/magazine\/tagged\/foodies-walhalla",
"title": "Foodies Walhalla",
"count": "2"
},
"magazine": {
"id": "9744",
"url": "blogs\/magazine\/tagged\/magazine",
"title": "magazine",
"count": "6"
}
}
},
"3744": {
"id": 3744,
"image": 7442425,
"url": "blogs\/magazine\/beauty-artikel-2",
"title": "Beauty artikel 2",
"author": "",
"author_url": false,
"summary": "beauty article 2",
"content": "dfg sfg sdfg sdfgd gdsf df gsdf gdsf g",
"date": "2013-11-13 11:21:00",
"comments": [],
"comments_count": 0,
"tags": {
"beauty": {
"id": "9792",
"url": "blogs\/magazine\/tagged\/beauty",
"title": "beauty",
"count": "2"
},
"healthy": {
"id": "9745",
"url": "blogs\/magazine\/tagged\/healthy",
"title": "healthy",
"count": "2"
},
"magazine": {
"id": "9744",
"url": "blogs\/magazine\/tagged\/magazine",
"title": "magazine",
"count": "6"
}
}
},
"3745": {
"id": 3745,
"image": 7442417,
"url": "blogs\/magazine\/love-life-1",
"title": "Love & Life 1",
"author": "",
"author_url": false,
"summary": "dfgdsfgd",
"content": "f gdf gdfgdfg dfgdsfgdsfgdsfg",
"date": "2013-11-13 11:21:00",
"comments": [],
"comments_count": 0,
"tags": {
"love-life": {
"id": "9793",
"url": "blogs\/magazine\/tagged\/love-life",
"title": "love & life",
"count": "2"
},
"magazine": {
"id": "9744",
"url": "blogs\/magazine\/tagged\/magazine",
"title": "magazine",
"count": "6"
}
}
},
"3746": {
"id": 3746,
"image": 7442388,
"url": "blogs\/magazine\/love-life-2",
"title": "Love & Life 2",
"author": "",
"author_url": false,
"summary": "dfkjghksdjfh gdskfjdj sdlkjfhdjfghdjklfsdfkjhg df gd ghdkjsfhgkjsd fg lkjdshklgdfh kjds glkjsdh kljdsfh",
"content": "dfkjghksdjfh gdskfjdj sdlkjfhdjfghdjklfsdfkjhg df gd ghdkjsfhgkjsd fg lkjdshklgdfh kjds glkjsdh kljdsfh",
"date": "2013-11-13 11:21:00",
"comments": [],
"comments_count": 0,
"tags": {
"love-life": {
"id": "9793",
"url": "blogs\/magazine\/tagged\/love-life",
"title": "love & life",
"count": "2"
},
"magazine": {
"id": "9744",
"url": "blogs\/magazine\/tagged\/magazine",
"title": "magazine",
"count": "6"
}
}
}
}
},
"request": {
"url": "http:\/\/taj-ringen.webshopapp.com\/blogs\/magazine\/?format=json",
"method": "get",
"ssl": false,
"get": {
"format": "json"
},
"post": [],
"device": {
"platform": "windows",
"type": "webkit",
"mobile": false
}
},
"template": "pages\/blog.rain",
"renderer": "json"
}
JAVASCRIPT
<div id="loadstatus"></div>
<script type="text/javascript" language="javascript">
var newresult = '';
$.ajax({
type: "GET",
url: "http://taj-ringen.webshopapp.com/blogs/magazine/?format=json",
data: "",
dataType: "json",
success: function (mydata) {
console.log('load successful');
console.log('mydata.blog.articles.length: ' + mydata.blog.articles.length); //'undefined' error
for (var i = 0; i < mydata.blog.articles.length; i++) {
newresult += mydata.blog.articles[i].title;
}
}
});
</script>
I also had a look at this post: Convert Object to JSON string
tried the jQuery.parseJSON function
console.log(mydata);
var tmp = jQuery.parseJSON(mydata);
console.log(tmp);
console.log('tmp.blog.articles.length: ' + tmp.blog.articles.length);
But there I get an error Uncaught SyntaxError: Unexpected token o on line jquery-1.10.2.min.js:4
tried the $.map function
var array = $.map(mydata, function (e) {
return [$.map(e, function (v) {
return v;
})];
});
console.log(array);
console.log('tmp.blog.articles.length: ' + array.blog.articles.length);
Here I get Uncaught TypeError: Cannot use 'in' operator to search for '14' in pages/blog.rain on line jquery-1.10.2.min.js:4
What I'm trying to to is convert the object that is returned by the site and be able to loop through it.
Iterate through the article object, pulling out the keys associated with each article using the method described in the below post:
How to list the properties of a JavaScript object
You could also use the following loop:
for(var article in blog.articles) {
console.log(blog.articles[article].title);
}

Resources