rcdmk / aspJSON

A fast classic ASP JSON parser and encoder for easy JSON manipulation to work with the new JavaScript MV* libraries and frameworks.
MIT License
204 stars 89 forks source link

Encoding Issue - loop's. #96

Closed tomaslind closed 2 years ago

tomaslind commented 4 years ago

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 `

rcdmk commented 4 years ago

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?

tomaslind commented 4 years ago

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`

rcdmk commented 2 years ago

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