Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google appengine, ndb, and Json

I have an attribute that I'm storing as a JSON object, like so:

content  = ndb.JsonProperty()

When I do this, I get this error:

   line 1614, in _to_base_type
    return json.dumps(value, 2)
AttributeError: 'module' object has no attribute 'dumps'

inside the ndb model class.

As a ndb.TextProperty it works properly. Maybe I'm sending the JSON wrong, this is the JSON object I'm sending:

{posttext: "What is your earliest memory of WWII?", linkdata: ""}
like image 878
prashn64 Avatar asked Dec 16 '22 01:12

prashn64


1 Answers

Do you perhaps have a module named 'json.py' or a package named 'json' in your app? That would override the json module that ndb is trying to import. The solution is to pick a different name for that module or package.

like image 85
Guido van Rossum Avatar answered Jan 01 '23 12:01

Guido van Rossum