Error parse json

Hello guys, im trying to pase a json with:

return [{json:{new_value:JSON.parse(items[0].json.propertyName)}}];

but im geting this error: ERROR: Unexpected token in JSON at position, but this only happens when I put it as an expression of an output.

When I try to perform the same process but using a manual variable with the same json body, works normally

I created two variables one coming from the text of imap, is a json.
Another, I put the json manually in the variable to test.

When

return [{json:{new_value:JSON.parse(items[0].json.propertyName)}}];

output error

but, when

return [{json:{new_value:JSON.parse(items[0].json.propertyName1)}}];

Works

My question is: why can’t i convert to json if the text is identical?

{
  "nodes": [
    {
      "parameters": {
        "format": "resolved",
        "options": {}
      },
      "name": "IMAP Email",
      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 1,
      "position": [
        470,
        280
      ],
      "credentials": {
        "imap": "outlook"
      }
    },
    {
      "parameters": {
        "functionCode": "return [{json:{new_value:JSON.parse(items[0].json.propertyName)}}];"
      },
      "name": "Function1",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1050,
        280
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "value": "={{$node[\"Set1\"].json[\"email\"]}}"
            },
            {
              "name": "propertyName1",
              "value": " {\n\n\"O status da Reserva é\" : \"testando\",\n\n\"ID da Reserva\" : \"OD02G\",\n\n\"Unidade\" : \"Cabanãs Antílope - Quádrupla\",\n\n\"Origem\" : \"IntegraNinja\",\n\n\"Nome do Hospede\" : \"Eduardo Cuenca\",\n\n\"Número de hospedes\" : \"4\",\n\n\"Telefone\" : \"+54 9 11 5157 3630\",\n\n\"Check-in\" : \"10 fev 2021\",\n\n\"Check-out\" : \"16 fev 2021\",\n\n\"Total de diárias\" : \"6\",\n\n\"Valor total da reserva\" : \"ARS 36.000,00\",\n\n\"Valor quitado\" : \"ARS 36.000,00\",\n\n\"Valor a pagar no check-in\" : \"ARS 0,00\",\n\n\"Proprietário\" : \"Alejandro Lopez\",\n\n\"Telefone proprietário\" : \"+5493541543759\",\n\n\"Link da Reserva\" : \"https://www.multitemporada.com/i/reservation/OD02G\",\n\n\"Observação\" : \"YA vio la cabaña (quiere individual) Pago de contado efectivo\"\n\n}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        840,
        280
      ]
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "email",
              "value": "={{$node[\"IMAP Email\"].json[\"text\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set1",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        660,
        280
      ]
    }
  ],
  "connections": {
    "IMAP Email": {
      "main": [
        [
          {
            "node": "Set1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Function1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set1": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Hey @Alexandre_Magno!

The propertyName is already a valid JSON. You’re trying to convert a JSON into a JSON and that is the reason why you’re getting the error. propertyName1 isn’t a valid JSON, it is a string that contains the data in a JSON format. JSON.parse() method converts JSON strings into JSON.

If you still want to try something similar for propertyName you will have to convert the JSON object into a string using the JSON.stringify() method, and then use the JSON.parse() method. This is however not needed, since it is already in JSON!

I hope this makes sense.