Json object is empty but node disagrees

I’m checking if the json has a field using $json.hasField(“paywall”) and the expression returns the correct answer but somehow the output doesn’t. Is this a bug or am I missing something?

Information on your n8n setup

  • n8n version: [email protected]
  • Database (default: SQLite): -
  • n8n EXECUTIONS_PROCESS setting (default: own, main): -
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: -

Interesting.

I wonder if false is not actually parsing as falsey, there may be extra characters for some reason. Can you try set the object type from Boolean to String and see if it retains the value? (Not saying this is solution, just want to see if that changes the output)

Tried, didn’t change the output. Also tried going with JSON, same result.

{
  "paywalled": {{ $json.hasField("paywall") }}
}

Perhaps try:

$json.paywall !== undefined
or
('paywall' in $json)

2 Likes

Yeah that worked, thanks!

1 Like

Awesome I am glad! Would appreciate if you could mark my response as the solution :slight_smile:

Sure! It did solve the problem but I hope the devs take a look at it tho since it’s probably a bug no?

Anyway, thanks again

1 Like

Awesome I am glad. I am unsure, it may in fact be a bug. There are no bug reports for this on github tho. GitHub · Where software is built

The function exists in the documentation, but I have not used it before to confirm. You may be right. What does the input data look like exactly?