[Solved] SyntaxError: Unexpected end of JSON input

Note: When doing a project, I encountered the need to transfer a line of data objects to another page, using JSON.stringify => JSON.parse and then transferring it by url:

Then the error is reported as follows:

Later, after reviewing the relevant information, we found that we need to add a coding and decoding process, as follows:

After printing, the object appears:

Cause analysis:

Reason: If an address is encountered in the parameters of the object or the elements of the array, and the address includes ? and & these special symbols, the object/array must first be converted to a string by JSON.stringify and then encoded by encodeURIComponent, when received, first decoded by decodeURIComponent and then converted to JSON format object/array by JSON.parse

Read More: