Prometheus
Prometheus

Reputation: 33605

Django JSONField is adding extra characters u, why?

I'm using JSONField here for example:

sets = JSONField(null=True, blank=True)

However, when my app (Native not Python) writes to the API Django stores with extra character i.e. " becomes u', Why is this and how do I stop it?

Example returned data...

"sets": "{u'position': {u'y': u'-121-07', etc...

Upvotes: 1

Views: 372

Answers (1)

SaeX
SaeX

Reputation: 18681

The u is added by Python 2.x as JSONField is using unicode strings.

They do no harm. However, if you don't want to see this, you might try Python 3.x since strings are u by default there.

See also Suppress the u'prefix indicating unicode' in python strings.

Upvotes: 1

Related Questions