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
1
vote
1 answer

parsing in array into nested object

im looking to have an end result where i passed in array values based on a key to "OR" an OR array. whereConditions = { "AND": [ { "OR": [ { "alert_type_id": { "equals": "9" } }, …
Joseph Ng
  • 113
  • 1
  • 7
1
vote
1 answer

Remove nested object in React State

In React I have some filters in a state: this.state { filters: [countries: {parameterName: 'country', value: 'England'}, {parameterName: 'country', value: 'Greenland'}] } In an onClick-Handler function I receive one of…
Jeremy
  • 270
  • 5
  • 19
1
vote
3 answers

Javascript: How to update a nested json, given the key PATH like doc.field1.field2 as string

I am trying to update a nested JSON which is given as an input, e.g.: { "doc": { "a1": { "b1": 1, "b2": [ "one", "two" ] }, "a2": "xyz" } } The JSON…
AJS
  • 13
  • 2
1
vote
1 answer

Checking for duplicate property values in an array of nested objects

I have a JSON file with an array that has nested objects and arrays that simulates a shopping cart. I want to check for duplicate values and if there are any, update the quantity value of the item otherwise, just add the items to the cart. Here is…
PalesaDev
  • 67
  • 6
1
vote
1 answer

How to push an object coming from postman to nested object?

I'm having a problem in pushing these data to an nested object. Here is what I put on postman as JSON format: "productId":"621256596fc0c0ef66bc99ca", "quantity":"10" here is my code on my controller module.exports.createOrder = async…
1
vote
1 answer

Combine duplicate tokens inside huge JSON file into nested array of objects using React

I looked at several of the suggested solutions but none seemed to rise to this confounding data formatting challenge. I have a huge JSON file (over 100k rows) and massive duplicates of data all as top level objects. Here's an example: [ { …
Mitch Moccia
  • 519
  • 2
  • 8
  • 23
1
vote
2 answers

Handlebars - Nest objects in #each

I use express-handlebars with Node JS and I am trying to display informations from the array games on my HTML page using #each. But handlebars won't display the values inside my object. Even if it is not a nested object. But if I only write…
1
vote
2 answers

How to update a nested object child element, where some condition(s) is/are true

Note: This is not a duplicate question, please read till the end and see the included image. I have a nested object and an array field inside my collection/document in Firestore. Main categories Drinks Snacks Items for Drinks are (Water, Energy,…
1
vote
2 answers

JavaScript - Edit nested objects

I have one array of nested objects. I want to edit each of them and add property "status" and value of this property can be "selected", "unselected" or "indent". 1. status: 'selected' his lvlScope array is not empty lvlScope array of all his…
kasp3rsky
  • 127
  • 1
  • 3
  • 15
1
vote
0 answers

Nested object in form data

I'm trying to do a post request with an object inside an object. My JSON body should look like this: { "name": "Dish name", "description": "Dish description", "allergies": "Dish allergies", "price": "12", "category": { "id": "1",…
Milofow
  • 11
  • 1
1
vote
1 answer

Accessing the data inside an object when you dont know the name of the key

I have a set of data where the key on the data is not predictable. I am trying to read the nested object but I cant seem to access it so I can check the value of the next key Physicians or NonPhysicians. I tried using the key of the nested value to…
CourtneyJ
  • 458
  • 6
  • 19
1
vote
1 answer

Modify array of the nested objects by its nested object's properties

I have the following structure in my array. const data = [ { name: 'Book_1', value: { eng: 'english_book_1', sp: 'spanish_book_1' } }, { name: 'Book_2', value: { eng: 'english_book_2', sp:…
zana10
  • 113
  • 1
  • 8
1
vote
3 answers

How to dynamically add data from an array with objects to a nested array?

I have this set of data that I get dynamically - This is the data I dynamically get and my question is how can I get the values from the key, pattern and label and put them in a nested object like this - how should the nested object look like. My…
bnn16
  • 13
  • 2
1
vote
1 answer

Inserting Nested Objects EF Core 5

I have the following entities: Batch Samples SampleContainers SampleTests A batch contains many samples. A sample contains many SampleContainers and many SampleTests. I am trying to make a copy of batch and insert into database. Attempt #1: get…
Samra
  • 1,815
  • 4
  • 35
  • 71
1
vote
1 answer

Rendering nested object properties from API call in react

I am trying to render text from an API call, text or numbers that are directly accesible from the axios.data object can render normally, nevertheless when inside the axios.data there is another object with its own properties I cannot render because…
Walter
  • 19
  • 1
  • 6