Search for JSON property -> swtich if match/ not match

Hey is there a way to search in a JSON data for a property for example key, if its there under the part msg.payload or like msg.payload.js than filter for this {the function for filter i got}, and if it is not there give an error phrase like undefined{this function i got too}, but i don't know how i can search for a JSON data property for the switch, i tried regex or contains, but not works..

Please read This post which should help to clarify the difference between Javascript objects and JSON, and then decide whether you need to rephrase your question.

i know the difference between them, but that is not answering my question..

The switch can test for a key

image

but it wont search for a key in sub properties.

If you want tot search full object and all sub properties, you can achieve that easily with a function node

ok key works well, if i go for sub properties i just need to go for the next higher part in property and it works. thanks for the answer. You can close the topic so :slight_smile:

So it isn't JSON (which is a string), it is a javascript object.

it is JSON, i get it from device Dashboard. i split it into objects after "\n", so its JAVA Objects.
If ur just here colin to show how clever u are, stop answering. i had a question and steve helped me well. ur just giving not helpful information for exactly that question.

The point is that the question was not clear. You asked how to 'search in a JSON data for a property', which implies that you want to search a string, whereas what you wanted to do was to access a property in a javascript object.

Javascript. Java is very different again.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.