"bank_account": Object {
"name": "User Name",
"account": "4916111323",
"bank": "City Bank",
},
here i can call
item.bank_account.name
item.bank_account.account
item.bank_account.bank
but here its not working
item.menu.image
"menu": Array [ Object {
"image": "3",
"item_id": "1",
"price": "450"},
],
should be something between menu and image because it object?
item.menu is Array. You need to access it's indexes: item.menu[INDEX].image (index is a zero-based index) e.g. item.menu[0].image
Related
I have some monotonous Json response in which I am trying access element of dictionary of array of dictionary of array using node.js but hard luck and unable to do so. I have tried accessing this stackoverflow solution https://stackoverflow.com/questions/30448517/node-js-how-to-access-values-of-dictionary-within-an-array-of-a-key-in-a-dicti but in my case this is not working appropriately. My Json response is :
{
"client": [
{
"code": [
{
"id": "001",
"code": "100",
"type": "New"
},
{
"id": "002",
"code": "200",
"type": "Old"
}
]
}
]
}
From this response I want to get value of each "id", "code" and "Type". Any valuable answer would be appreciated. Thank you !!!
If your json was assigned to the variable x
x = {
"client": [
{
"code": [
{
"id": "001",
"code": "100",
"type": "New"
},
{
"id": "002",
"code": "200",
"type": "Old"
}
]
}
]
}
console.log(x["client"][0]["code"][0]["id"])
(I'll leave iterating through the arrays as an exercise for the reader)
I want to fetch the given JSON data to a mustache template.
{
"1": {
"feedbackid": "1",
"name": "Harshad",
"email": "harshadbindra#gmail.com",
"message": "asdasdf"
},
"2": {
"feedbackid": "2",
"name": "Tom",
"email": "tom#gmail.com",
"message": "test"
},
"3": {
"feedbackid": "3",
"name": "Harshad",
"email": "harshadbindra#gmail.com",
"message": "asdfasdfas"
}
}
All this data is contained in a variable $data. So, how can you access it within the .mustache file?
Thanks in advance.
My data looks like:
[
{
"_id": "531dbf8b9b9fc50000a8d611",
"active": true,
"client": {
"_id": "531dbf8b9b9fc50000a8d60e",
"name": "TR"
},
"company_id": "531dbf8b9b9fc50000a8d60c",
"createdOn": "2014-03-10T13:35:07.313Z",
"description": "Gentle Action Application Pads",
"dimensions": {
"weight": 22.4
},
"lot": [
],
"meta": {
"category": "Face",
"msrp": 7.75
},
"sku": "11002",
"unit_of_measure": "each",
"updatedOn": "2014-03-10T13:35:07.314Z"
},
{
"_id": "531dbf8b9b9fc50000a8d612",
"active": true,
"client": {
"_id": "531dbf8b9b9fc50000a8d60e",
"name": "TR"
},
"company_id": "531dbf8b9b9fc50000a8d60c",
"createdOn": "2014-03-10T13:35:07.317Z",
"description": "Skin Renewal System - Enriched (CA)",
"dimensions": {
"weight": 22.4
},
"lot": [
],
"meta": {
"category": "Face",
"msrp": 321.6
},
"sku": "11700CA",
"unit_of_measure": "each",
"updatedOn": "2014-03-10T13:35:07.318Z"
}
]
In my view, I have:
<input type="text" ng-model="receivingSku" placeholder="Locations loaded via $http" typeahead="sku for sku in getSku($viewValue) | filter:$viewValue" typeahead-on-select="selectedSku()" class="form-control">
I need the sku field for each item to be in the typeahead. How can I accomplish this?
Presently, I get an error:
Error: matches is undefined
You can loop over your original array and create an array of just SKU's:
var skus = origArray.map(function(e) {
return e.sku;
});
The new array can be used for typeahead.
PS - I'm not very familiar with typeahead. If typeahead is capable of peeking into objects, you don't need to do this.
I am working on an application in Backbone.js and Jquery which requires a JSON to be like this:-
{
"FolderSummaryResponse": {
"Status": "SUCCESS",
"FolderItem": [
{
"Desc": "Immediate Action Required",
"ID": "1",
"RecordCnt": "0",
"SeqCd": "1",
"SubFolderItemList": {
"FolderItem": [
{
"Desc": "Customers to Call",
"ID": "10",
"RecordCnt": "0",
"SeqCd": "0"
},
{
"Desc": "PO Connect",
"ID": "17",
"RecordCnt": "0",
"SeqCd": "7",
"SubFolderItemList": {
"FolderItem": [
{
"Desc": "Inbound",
"ID": "73",
"RecordCnt": "0",
"SeqCd": "0"
},
{
"Desc": "Outbound",
"ID": "74",
"RecordCnt": "0",
"SeqCd": "1"
}
]
}
}
]
}
}
. Basically a parent and children kind of structure. How can I a create a Model and collection for this in backbone? Please help me as I am completely new to backbone.js .
There is a JavaScript library that sits on top of Backbone.js that reduces the amount of boiler plate code you have to write and they have a CompositeView that works best with nested collections. I've included the documentation and an article that discusses using it.
Marionette CompositeView documentation
Marionette CompositeView Article
I am using Backbone.js, unexpectedly i am in the confused position now, because of this scenario..
my test object :
test: {
"links": {
"nameLink": {
"name": "name 1",
"name": "name 2",
"name": "name 3"
},
"ageLink": {
"age": "1",
"age": "2",
"age": "3"
}
},
"data": {
"element": {
"project": "project 1",
"title": "title1",
"brand": "brand1"
},
"element": {
"project": "project 2",
"title": "title2",
"brand": "brand2"
},
"element": {
"project": "project 3",
"title": "title3",
"brand": "brand3"
}
}
}
I do have the josn data from server, it has the project name, links(there is nested links under), time stamps.
how can i split the data, and append appropriate UL elements. ( by name, by age ect.)
On click on the name, age links, how can sort (by name, age) the datas i appended to body tag? - without sorting the links menu?
How can i keep all this updated?
any good suggestion please?