xxxxxxxxxx
Make sure your keys are compatible by NOT containing dots and spaces.
xxxxxxxxxx
try {
const jsonString = '{"name":"John","age":30}'; // Your JSON input
// Parsing the JSON input
const parsedJson = JSON.parse(jsonString);
// Use the parsed JSON data as needed
console.log(parsedJson);
} catch (error) {
// Handle the "Unexpected end of JSON input" error
if (error instanceof SyntaxError && error.message.includes('JSON')) {
console.error('Invalid JSON input:', error);
} else {
console.error('Unexpected error occurred:', error);
}
}
xxxxxxxxxx
[Solved] Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse