pbojinov
9/3/2013 - 11:30 PM

Removing improperly formatted JSON library in progress.

Removing improperly formatted JSON library in progress.

/**
 * 1. utf-8 BOM bytes get translated to \ufeff. Unicode character "Zero width no-break space", can't see them...
 * 
 * Example: Node crashes when trying to parse JSON with BOM as first character
 * 
 *     {"Location":{"City":"AMSTERDAM","Country":"NETHERLANDS","CountryCode":"NL","I
 *     ^
 *     SyntaxError: Unexpected token
 *        at Object.parse (native)
 */
var response = '', //place response with BOM as first character here

response.charCodeAt(0) === 65279;       //test to see if BOM character is the first character
response = response.replace(/\ufeff/g, ''); //Remove BOM character
response.charCodeAt(0) === 123;             //test to see if its gone, 123 is ASCII Code for {