Got a null object in array
See original GitHub issueHi everyone,
I would like to select themes that have an items
array.
Data origin :
{
"themes": [
{
"id": "122jj23164-8202-4da2-901e-1237f1236",
"name": "Push Products N1"
},
{
"id": "123fklj786-8202-4da2-901e-87123873",
"name": "Push Products N2",
"items": {
"item": [
{
"id": 19812,
"attribute": [
{
"name": "second-id",
"value": {
"content": 19812
}
},
{
"name": "wording",
"value": {
"content": "A product"
}
}
]
},
{
"id": 87613,
"attribute": [
{
"name": "second-id",
"value": {
"content": 87613
}
},
{
"name": "wording",
"value": {
"content": "Sample"
}
}
]
}
]
}
}
]
}
Jolt :
[
{
"operation": "shift",
"spec": {
"themes": {
"*": {
"items": {
"@(1,id)": "themes[&2].id",
"@(1,name)": "themes[&2].name",
"item": {
"*": {
"id": "themes[&4].products[].id",
"attribute": {
"*": {
"value": {
"content": "themes[&7].products[&4].@(2,name)"
}
}
}
},
"id": "themes[&3].products[&3].id",
"attribute": {
"*": {
"value": {
"content": "themes[&6].products[&6].@(2,name)"
}
}
}
}
}
}
}
}
}
]
I don’t understand why I got a null at the first index on my themes
array.
{
"themes" : [ null, {
"id" : "123fklj786-8202-4da2-901e-87123873",
"name" : "Push Products N2",
"products" : [ {
"id" : 19812,
"second-id" : 19812,
"wording" : "A product"
}, {
"id" : 87613,
"second-id" : 87613,
"wording" : "Sample"
} ]
} ]
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
Null Values in array of objects - javascript - Stack Overflow
Null Values in array of objects ... I am creating objects when textbox having some values (using ng-blur and textbox.value!==undefined ) and then ......
Read more >Is there any way to check if there is a null value in an object or ...
To check if there is a null value in an object or array, use the concept of includes(). Example. Following is the code...
Read more >Java - Check if Array is Empty - Tutorial Kart
To check if an array is null, use equal to operator and check if array is equal to the value null. In the...
Read more >Everything you wanted to know about $null - PowerShell
What is NULL? You can think of NULL as an unknown or empty value. A variable is NULL until you assign a value...
Read more >Java NullPointerException - Detect, Fix, and Best Practices
1. NullPointerException when calling an instance method · 2. Java NullPointerException while accessing/modifying field of a null object · 3. Java ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You need to do two shifts.
First shift only passes thru elements of the “theme” array that are “valid”, where valid means I think means “it has at least one element of in the item.items array”.
Then do the rest of the transform as normal.
Yes exactly. I was thinking JOLT do it natively by removing null object in array