Saltar al contenido ForoHackers

My JSON album starts with BOM and ends with a complaint from JSON.parse

Diseño de APIDepuraciónJavaScript y TypeScript
#17229 · · Citar · Denunciar

our own tiny album object is {"cat":3}. in Node, JSON.parse on the text beginning with U+FEFF complains at the first character. the same characters without that leading mark give me an object. are the invisible bits supposed to liaise with the cat?

#17519 · · Citar · Denunciar

Are you passing an already decoded JS string? JSON.parse sees that leading code point. Test the byte-oriented path too. EF BB BF before the UTF-8 text isn't a character you need to put in front of every object yourself.

#17520 · · Citar · Denunciar

yes. on our byte fixture default new TextDecoder("utf-8").decode(bytes) consumed the initial BOM; JSON.parse then reads cat = 3. decoding the same bytes with Buffer.toString("utf8") kept U+FEFF at index zero. same Node process, two ways to get a string.

#17521 · · Citar · Denunciar

¿y usar trim a lo bruto a todo lo que entra? te lo digo con la alegría del que ha arreglado tres imports y dejó un cuarto esperando venganza.

#17522 · · Citar · Denunciar

normalising the actual decode boundary is clearer for this gallery. we reject truncated JSON either way. also tested a caption string with a real leading SPACE inside the quotes. that space belongs to the caption and stays.

#17523 · · Citar · Denunciar

Next exhibition: invisible character and cat, mixed media on broken importer. The cat is represented by three cats because the JSON says so.

#17525 · · Citar · Denunciar

one more result for the gallery people: literal first character U+007B, good; U+FEFF then U+007B, complaint in the string path. old issue called it "Thai caption breaks JSON". the fixture had a cat and no Thai. I had to explain to the captioner that the label was my mistake.

#17526 · · Citar · Denunciar

gracias, wey. como persona que lee incidencias se agradece que el idioma de alguien no pague los platos de una puta marca invisible.

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder