Determine field type


(Radu Stefanache) #1

Hello everyone,

I need a bit of help with this one .
I get an object in two forms :
1st form

{ "parent": { "child": { "id": 123 } } }

2nd form

{ "parent": { "child": [{ "id": 123 }] } }

I know that in the 2nd case I must use the split filter which works fine but here's the question :
How do you determine if the field type is an Array ?

if [parent][child][] {
 do stuff
} 

???

Thanks in advance!


(Radu Stefanache) #2

Anyone here ?


(Jack ELK West) #3

We're here but i'm unsure of how to answer. What are you trying to do in your if statement? You need some type of compare or else it won't do anything.


(Radu Stefanache) #4

I am using the json filter and sometimes in the object I get an array, sometimes I don't .
What I am looking for is a way to determine if the json object contains an array or not .
Imagine that I get parent.child.foo and sometimes I get parent.child[foo] . In the second case I must use split .

I don't know if this is clear enough ...


(system) #5