Getting object type in python code node

Describe the problem/error/question

I’m tying to get the type of a value in the input json using the python code node but it seems I’m getting <class ‘pyodide.ffi.JsProxy’> objects. Even if it’s a wrapper object they don’t seem to be an instance of a list. I was wondering how i can i get the actual type.

What is the error message (if any)?

None

Please share your workflow

Share the output returned by the last node

[
{
“value”: [
“list”,
“of”,
“values”
],
“type”: “<class ‘pyodide.ffi.JsProxy’>”,
“is_instance”: false
}
]

Information on your n8n setup

  • n8n version: 1.85.4
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own, main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: windows

Hey @yoyo1 hope all is well, try this instead:

value =  _input.item.json.Test

return {
  "value": value,
  "type": f"{type(value.to_py())}",
  "is_instance": isinstance(value.to_py(), list)
}
2 Likes

It’s working thank you!

1 Like

Or even better:

value =  _input.item.json.Test.to_py()

return {
  "value": value,
  "type": f"{type(value)}",
  "is_instance": isinstance(value,list)
}
2 Likes

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