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

299
Visualizações
Issue sending over JSON as string from POSTMAN to node server

I have some json that looks like this:

const json = {
   "name": "Peter",
   "age": 21
}

Then I call JSON.stringify(json) which gives me the following:

'{"name":"Peter","age":21}'

I want to send data from the UI to my server. Currently I am using POSTMAN for this.

POST
http:localhost:8888/user
Body -> JSON

{
  "user": { 
     "details": '{"name":"Peter","age":21}',
     "foo": "bar"
   }
}

details here needs to be a string but when I send over the data I get the following error on the server

SyntaxError: Unexpected token } in JSON at position 114

Does anyone have any ideas here?

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

0

JSON does not allow for single quotes, what you are trying to send is invalid. What you need to do is use double quotes and escape the internal quotes for the JSON key/values:

{
  "user": { 
     "details": "{\"name\":\"Peter\",\"age\":21}",
     "foo": "bar"
   }
}
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