Reputation: 657
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: ""}
Upvotes: 4
Views: 1053
Reputation: 101149
What you're describing works fine when I try it:
from google.appengine.ext import ndb
class TestModel(ndb.Model):
foo = ndb.JsonProperty()
t = TestModel(foo={"posttext": "What is your earliest memory of WWII?", "linkdata": ""})
t.put()
Key('TestModel', 7001)
Can you go into more detail about exactly how you're doing this? How does it differ from the snippet above?
Upvotes: 1
Reputation: 16890
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.
Upvotes: 11