Today encounter a JSON data transfer object fails the amount of problems, beginning service returns json is not very clean, the beginning and end of a line break, obviously not in conformity with the json format JSON.parse certainly given it
Here to tell us the location of the first word json is not expected. Then the first line break is replaced with a positive
Regular replaced over the data, we can see the data and common json format the same, but when converted to an object or an error, the error is still the beginning of the prompt Unexpected token in JSON at position 0
Then again this string of separate strings out and turn in a browser in the node, and all the success! what? ? ? I met a ghost? ? ?
Take a deep breath, calm down, that we first make a variable length print length, and will be replaced after printing directly to the length of this string compare and see
Our eyes have seen the length of the string is 896, but the actual length of the variable is indeed 897, see the error message prompt is in conjunction with the first character of exceptions, basically to determine the source of that we do not see that the first character, then Dir see what it is a character,
Than meets the eye, in fact, not so much strange question, careful analysis of the information currently available, the patient thought, to cross check information, after all, the truth will emerge.