Questions tagged [nested-object]

Objects are composite data types which are built from primitives and other objects. An object’s building blocks are commonly referred to as its "fields" or "properties" comprising of `key -> value` pairs. A nested object is basically a data structure where an object refers to other objects, i.e. an object's values is another object or another set of objects. Such nested structures can be accessed by consecutively applying dot notation or bracket notation.

Objects are composite data types which are built from primitives and other objects. An object’s building blocks are commonly referred to as its "fields" or "properties" comprising of key -> value pairs.

A nested object is basically a data structure where an object refers to other objects, i.e. an object's values is another object or another set of objects.

A nested object structure can be accessed by chaining dot notations or bracket notations. For example, in the following, if we want to access the first a property from nestedObject1:

obj = {
    a: "1",
    nestedObject1: [{
        a: "2",
    }, {
        a: "3",
    }]
};

Using dot notation, we can access that property like this:

obj.nestedObject1[0].a

//will return the value "2" of the first property `a` from nestedObject1

Using bracket notation, we can access that property like this:

obj["nestedObject1"][0]["a"]

//will return the value "2" of the first property `a` from nestedObject1
267 questions
2
votes
1 answer

How do I populate a field nested in array of objects using aggregation only in mongoose?

I am trying to populate a deeply nested object in an array for quite some time but is of no luck. I tried unwinding the array but the resultant array is being converted into an object instead of an array. let aggQuery: any = [ { $match:…
Rajat
  • 45
  • 5
2
votes
1 answer

Angular 2: Change Detection of array inside the object

I have an object as follows which comes through @Input. @Input() data; //** { "class_a":["John","Harr y"], "class_b":["Joseph","Phlip","David"], "class_c":[] } **// I need to detect the changes if data added or removed in class_a or class_b…
Tom
  • 183
  • 1
  • 1
  • 9
2
votes
1 answer

TypeORM save nested objects

I'm working on a express (with TypeORM) + ReactJS app. The problem is that I have 3 entities linked by OneToMany relationship like this: customer product(linked to customer) model(linked to product) import { Product } from…
nipuro
  • 310
  • 5
  • 22
2
votes
1 answer

How to do match multiple nested object in one document with inner hits in elasticsearch

How do I write a query with two search terms which matches nested objects with inner hits highlighted. Below is the sample usecase: I have a mapping: "mappings": { "properties": { "grocery_name": { "type": "text" }, …
2
votes
1 answer

JMeter PreProcessor - JSON EXtractor: Nested object

In the response body of my request, it receives the following JSON: `{"C6666111B946":{"status":"NOT-ADDED"}}` I need to get to the item "C6666111B946" to save it as a variable, so the question is what do I have to enter in the JSON Path expressions…
Ar2r
  • 55
  • 5
2
votes
0 answers

Figuring out how to best solve updating many fields based on nested ID with mongoose

I have been looking around here for a bit now but I can't really find anything that really answered the question or problem I have so I'm giving it a go in asking. I have a function in my REST API that gives the user right to terminate his or her…
2
votes
2 answers

How to create new object by two objects in javascript

I would like to know how to create new object by two objects in javascript. iterate through the obj1, and add the obj2 values, create new object in javascript function getObject(obj1, obj2){ let result={}; Object.keys(obj1).forEach(key=>{ …
ved
  • 167
  • 9
2
votes
2 answers

How can I render data within nested objects in react?

I am working with an API that contains nested objects and I am not sure how to display it. I am reading about using Object.keys but not sure how to do it... help please... Here is the react code. I need to render prices dynamically.
Blondish
  • 141
  • 1
  • 9
2
votes
0 answers

how to append nested object to FormData with .net core and angular 8

I am developing an application using angular as frontend and API in .net core. My API model is as below: class Tag { public int ID {get;set;} public string Name {get;set;} public string Description {get;set;} } And…
2
votes
2 answers

React Native Flatlist - How to loop through nested object

I have a JSON returned object from a file ./jsonData.json. Inside this file, I have this data: Note: This is the whole JSON data loaded from the file. import QuizData from './quizData.json' This is a new app, so QuizData is all of the following: [ …
JamesG
  • 1,552
  • 8
  • 39
  • 86
2
votes
0 answers

Mulitpart forms and nested objects Insomnia REST client

So I've decided to switch to Insomnia from Postman, as for some reason my Postman app keeps hanging. Everything is going well but I'm having trouble using multipart forms with Insomnia. How would I access this in Insomnia? In Postman I just need to…
Dipet
  • 323
  • 3
  • 14
2
votes
4 answers

dynamically flatten nested array of objects javascript

I'm trying to write a function that will accept a nested object array, and dynamically return the flattened result. arrayProperties.filter() is not returning an array of objects like I expect. const data = [ { parKeyA: "parValA", …
Brett B
  • 43
  • 1
  • 7
2
votes
1 answer

How can i handle django nested models?

I have a User, Post and Tag model in Django. Tag model is not relevant for this topic. I can get all the data to the front end with nested objects. In the other hand when i want to create a new post i send the post data to django and in django view…
2
votes
3 answers

Node Js - Flatten array of objects

I have an array like this var data = [ { family: "Fam A", category: "Cat A", products: [ { name: "Name A1", style: "Style A1" }, { name:…
Brett B
  • 43
  • 1
  • 7
2
votes
1 answer

Should REST API return nested objects or links to that objects?

What is the best practice in relation to this? Can you say that it depends on the application or is there any recommendation that indicates that one option is better than another? The two options are as follows: 1 - Return nested objects { "id":…
Mr. Mars
  • 762
  • 1
  • 9
  • 39
1
2
3
17 18