Issue with JSON content containing Arabic


#1

Greets :slight_smile:

So I have an app which is being rendered in 2 languages: English + Arabic.

It’s using a WordPress backend with the WP Rest API plugin which will allow the client to add new content to the app. The English part of the app is built and running smoothly.

However I’ve run into an issue when trying to use Arabic. When there’s Arabic in the JSON, I get an error along the lines of

Unexpected token W in JSON at position 0

When I remove the Arabic from the content so that the JSON is arabic free, problem goes away.

I’m assuming this is something to do with the encoding for Arabic etc?

Any thoughts to how I should be doing this to get around the problem?

TIA.


#2

Can you show us an example of the JSON that causes the problems?


#3

Sure: http://pastebin.com/e4DN1NnU


#4

http://jsonlint.com/ doesn’t seem to like that JSON either.

Maybe you can’t output Arabic this way in a JSON file?


#5

For anyone else who has this issue, the problem lay with the encoding of the Arabic data in WordPress.

This plugin solved the issue: https://wordpress.org/plugins/full-utf-8/