aspJSON
aspJSON copied to clipboard
Encoding Issue - loop's.
Hi
When I use following process to loop though a array (like JSONarr) which includes special characters like " É " in the JSON, they get currented/converted in the item. all the content type/charaterset is set to UTF-8 and LCID is set as well.
` dim i, item
more readable loop
for each item in JSONarr.items
if isObject(item) and typeName(item) = "JSONobject" then
item.write()
else
response.write item
end if
response.write "
"
next
`
Hi @tomaslind,
If you try to write the JSON string contents without parsing them, do you still get screwed results?
Can you please provide example data that would reproduce the issue in the snippet?
Thanks for a quick response...Below is an example
`Json Object Example
{ "data":[ { "id":1, "admin_name":"Round", "translation":[ { "language":"CA_en", "name":"Round" }, { "language":"CA_fr", "name":"Rond" } ] }, { "id":2, "admin_name":"Square", "translation":[ { "language":"CA_en", "name":"Square" }, { "language":"CA_fr", "name":"Carré" } ] } ] }
JSON_oa_shapes.parse(Json Object Example)
for each item in JSON_oa_shapes("data").items if isObject(item) and typeName(item) = "JSONobject" then item.write() else response.write item end if
response.write "<br>"
next`
Hi,
Sorry for the late reply. I hope you have figured it out already, but if not, that's an encoding issue with the way your server is set to write to the response.
Try setting Response.CodePage = 65001 ' Unicode and see if that helps.
If it helps, you can set that at session level, application level (web.config) or server level (IIS settings), depending on your needs.
You can easily find those settings with a quick search in Google.
Best, Ricardo