在gwt上解析json
服务器在此 fromat 中返回 json:
{
"appTarget":
{
"id":"3",
"teacher_id":"2",
"class_code":"0000",
"target_id":"2",
"course_id":"1",
"from_date":"2011-08-03",
"to_date":"2011-09-16",
"wpm":"30",
"acc":"43",
"success_per":"0",
"name":"Basic Course"
}
}
在 gwt 端,我创建了名为 JTarget 的 JS 覆盖类
,该类的属性与来自服务器的 json 相同。
我的问题是如何从传入的 json 文本初始化新的 JTarget 对象?
Server returns json in this fromat:
{
"appTarget":
{
"id":"3",
"teacher_id":"2",
"class_code":"0000",
"target_id":"2",
"course_id":"1",
"from_date":"2011-08-03",
"to_date":"2011-09-16",
"wpm":"30",
"acc":"43",
"success_per":"0",
"name":"Basic Course"
}
}
On gwt side i created JS overlay class named JTarget
and this class's atributes are the same to th json which comes from server.
My question is how can I initialize new JTarget object from coming json text?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个教程:
http://code。 google.com/p/google-web-toolkit-doc-1-5/wiki/GettingStartedJSON
Here is a tutorial:
http://code.google.com/p/google-web-toolkit-doc-1-5/wiki/GettingStartedJSON
JsonUtils< /code>
就是您要寻找的内容。
(尽管我怀疑您的 JTarget 实际上是用于内部对象,因此您必须使用
JTarget getAppTarget()
属性为容器对象创建一个覆盖层)JsonUtils
is what you're looking for.(though I suspect your JTarget is actually for the inner object, so you'd have to create one overlay for the container object, with a
JTarget getAppTarget()
property)