J
J
Jedi2018-12-17 10:45:02
JavaScript
Jedi, 2018-12-17 10:45:02

How to process JSON?

When interacting with the server, data is received in JSON format. But some data comes with a syntax error. Example: . For some reason, there is undefined at the beginning of the line. How can I check for undefined at the beginning of a string and remove it? undefined{cars: "BMW, LAMBA, PORSCHE"}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-12-17
@PHPjedi

How can I check for undefined at the beginning of a string and remove it?

Or maybe you'd better do it so that there are no undefined? - fix the server code.
If you want to go the way of the govnocoder: . str.replace(/^undefined/, '')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question