开发者

Why does appengine-rest-server return JSON strings even for integer properties?

I implemented a simple REST server on GAE using the appengine-rest-server. My DB开发者_Go百科 schema looks like:

SomeString = db.StringProperty()
SomeInt = db.IntegerProperty(default=0)
SomeFloat = db.FloatProperty(default=-1.0)
SomeDateTime = db.DateTimeProperty(auto_now_add=True)

When I do a Get with JSON output specified, I receive something like:

"EntityName":
{
    "SomeString": "Text"
    "SomeInt": "1"
    "SomeFloat": "1.0"
    "SomeDateTime": "2011-06-16T23:48:19.136146"
}

Any insight as to why the Int, Float and DateTime aren't correctly formatted as a such in the output? Does appengine-rest-server only output strings?


I believe it's because behind the scenes, appengine-rest-server uses xml for all of it's work. It then converts to JSON if it sees that in the accept-header. So, when it converts from xml, it's all strings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜