json - How can I stop CreateObject("msxml2.xmlhttp") from encoding HTML? -


i have vba script in ms access getting json output of web page. once retrieved process data using vba-json , insert access database. it's working beautifully.

this code retrieve json content:

with createobject("winhttp.winhttprequest.5.1")     .open "get", url, false     .setrequestheader "content-type", "text/html"     .send     htm.body.innerhtml = .responsetext     ' debug.print .responsestream end 

i ran little snag , can't find way around it:

within values of json, double quotes have been encoded " not break json. problem is, when retrieve json content of page, getting encoded ", makes json invalid.

how can tell not encode html values when retrieving or escape values doesn't break code? i'm guessing there may class use wouldn't have problem, after hours of searching, i'm stumped.

json text format language independent uses conventions. value can string in double quotes, or number, or true or false or null. definition of json can found @ http://www.json.org/.

json likes double quotes (as string delimiter).

&quot html 'encoding' because html doesn't double quotes, not json. if double quote if contained in json field takes html form " in order avoid confusion.

so, define variable string, dim a$ , set a$ = .responsetext in code , replace &quot single quote, i.e. chr$(39)

a$ = replace (a$, """, chr$(39)) 

after that

htm.body.innerhtml = a$ 

and have json-friendly text file.

funny note: in answer had write " code, elsewhere editor changed automatically string double quote (rendering in html!)


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -