question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Array of complex objects?

See original GitHub issue

What would that look like?

IE:

[
    {
        "name":"Apple",
        "binomial name":"Malus domestica",
        "major_producers":[
            {
                "name": "China",
                "amount": 100,
            }, 
            {
                "name": "United States",
                "amount": 200,
            }, 
            {
                "name": "Turkey",
                "amount": 300,
            }, 
        ]
    },
]

Would there just be a number added to the columns (fruit_major_producers_1_name, fruit_major_producers_1_amount)? What if fruit 2 (not pictured) had greater or less than fruit 1 number of major producers? Null columns?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vinay20045commented, Jun 1, 2018

If you can imagine each level 1 object to be a tree. Then, an array or an object, no matter at what nesting level it appears, will be reduced by following these 2 rules…

  1. The value will always be the leaf node. Ex: China or 100

  2. The key will be the concatenation of all parent node names with an ‘_’ as separator. Ex: fruit_major_producers_0_name or fruit_major_producers_0_amount 2.1. In case of Arrays, the immediate parent of the value is the index this is why the number 0 is appended, it is the index of that object within major_producers array

These rules from the post I referenced above…

screen shot 2018-06-01 at 7 22 50 pm

Hope it helps!!

0reactions
VictorioBerracommented, Jun 1, 2018

Helps a lot. Thanks for the quick replies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create array from complex array objects & loops in javascript
First of all, there are some error in your order array, note the difference between {} (for objects) and [] . Then it...
Read more >
Working With Complex Objects in Javascript
let's look back at the structure we saw, and see that the pieces are inside an array that's inside the store object. This...
Read more >
Data Structures: Objects and Arrays - Eloquent JavaScript
Objects allow us to group values—including other objects—to build more complex structures. The programs we have built so far have been limited by...
Read more >
8.4 Arrays of Objects
8.4 Arrays of Objects ... Complex[] points = new Complex [100];. This would create an array of 100 values (points [0], points [1],...
Read more >
Send arrays or complex objects - Nintex help documentation
You can send arrays or complex objects by configuring your OpenAPI Specification to use the complex object renderer. Note: It is not possible...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found