Transform hexcode "+" into "+" in Javascript

Asked

Viewed 43 times

0

I am using a payment API that requires the phone numbers reported to be in E.164 default (+[Código do país][código da cidade][numero de 8~9 dígitos]) and as a string (as in the example below).

However, by adding the +, he is transformed into +. Is there any way to transform this code to + again?

{
    "object": "customer",
    "id": 233406,
    "external_id": "#123456789",
    "type": "individual",
    "country": "br",
    "document_number": null,
    "document_type": "cpf",
    "name": "João das Neves",
    "email": "[email protected]",
    "phone_numbers": [
        "+5511999999999",
        "+5511888888888"
    ],
    "born_at": null,
    "birthday": "1985-01-01",
    "gender": null,
    "date_created": "2017-08-14T23:28:36.296Z",
    "documents": [
        {
            "object": "document",
            "id": "doc_cj6csivuv05zj696dkzzjbfmq",
            "type": "cpf",
            "number": "11111111111"
        }
    ],
    "addresses": [],
    "phones": []
}
  • 1

    Where is he transformed? Bring us more information

1 answer

0


Try

function htmlDecode(input) {
  var e = document.createElement('div');
  e.innerHTML = input;
  return e.childNodes[0].nodeValue;
}

console.log(htmlDecode("+"));

A lib he (for "HTML entities") is an entity encoder/decoder HTML robust written in Javascript. Design Here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.