Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
Parsing JSON into HTML

I'm fetching data from an API, and one of properties of the data is a description of the item, but the JSON response is written in HTML, and has <a></a> tags and other html elements in it. I would like to NOT display the tags and have them actually work.

for example, this is what its output to the screen:

"Here is the <a href='https://www.google.com'> Link </a>"

This is what it should look like:

"Here is the Link "

How can I achieve this?

(I'm using Next.js)

and this is how I'm displaying the data

<p>{description}</p>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try below. dangerouslySetInnerHTML is the JSX property you need.

<p dangerouslySetInnerHTML={{ __html: description }}></p>

Check the docs for more info

Working example

function App() {

  const description = "Here is the <a href='https://www.google.com'> Link </a>"; 

  return (
    <p dangerouslySetInnerHTML={{ __html: description }}></p>
  );
};


ReactDOM.render(
  <App />,
  document.getElementById('react')
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js"></script>
<div id="react"></div>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda