如何从 JavaScriptObject 读取 String[]? (GWT)
我正在从 JSON 创建一个具有 String[] 属性的对象,因此 JSON 如下所示:
{
key1: "val1",
key2: ["val2a", "val2b", "val2c"],
}
What's the best way to Define this as a JavaScriptObject?
现在我正在定义一个新对象 JSString,所以 java 对象看起来像这样:
public class MyObject extends JavaScriptObject {
...
public JSArray<JSString> getKey2() {...
}
这有点烦人。如果我能做到这一点那就太好了:
public class MyObject extends JavaScriptObject {
...
public String[] getKey2() {...
}
但这行不通。有更好的办法吗?提前致谢
I am creating an object from JSON that has a String[] property, so the JSON looks like this:
{
key1: "val1",
key2: ["val2a", "val2b", "val2c"],
}
What's the best way to define this as a JavaScriptObject?
Right now I am defining a new object JSString, so the java object looks like this:
public class MyObject extends JavaScriptObject {
...
public JSArray<JSString> getKey2() {...
}
This is kinda annoying. It'd be nice if I could do this:
public class MyObject extends JavaScriptObject {
...
public String[] getKey2() {...
}
But that doesn't work. Is there a better way? Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你看过
JsArrayString
吗?Did you look at
JsArrayString
?