views:

101

answers:

2

I am using JSON.parse for a list of products. I am running a regex to replace characters that were breaking the parse:

[\n|\t|\r]

It seems that I am still having issues when the following content is being copied into html.

<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: arial, Verdana, Helvetica; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">A soul mate for your aluminum group lounge chair. Rest your weary feet on this matching ottoman - same suspension design, same light weight, same elegant scale as the lounge chair. Polished aluminum 4-star base, black pedestal. Glides.</span></p>

Not sure which part is breaking the parser, and what I can do to fix it, short of removing the style and span tags.

A: 

You need to be more clear about exactly what steps you're taking between obtaining that HTML as a string, what you do to make it "JSON", and actually calling JSON.parse. Otherwise you're making it look like you're trying to use a JSON parser to parse HTML, which doesn't make sense.

that said, my guess is that it's the quote marks.

Breton
A: 

You shoudn't load HTML and CSS using JSON, load pure content and then wrap it into container. Maybe it will save a lot of hours of work in future.

Mike