首页 \ 问答 \ 将XML转换为JSON(Converting XML to JSON)

将XML转换为JSON(Converting XML to JSON)

我试图将XML文件转换为String类型的内部表格。 有没有将XML数据转换为JSON格式的功能模块?


I'm trying to convert an XML file into an internal table of type String. Is there a function module to convert XML data to JSON format?


原文:https://stackoverflow.com/questions/44260617
更新时间:2022-03-27 18:03

最满意答案

GWT VerticalPanel是ComplexPanel的子类,ComplexPanel是包含多个子窗口小部件的Panel的抽象类。 在ComplexPanel中(由VerticalPanel继承)是获取子窗口小部件数量,通过索引获取对它们的引用等的方法。 你可以构建一个像这样的迭代器:

Iterator<Widget> vPanelWidgets = myVerticalPanel.iterator();
while (vPanelWidgets.hasNext()){
  Widget childWidget = vPanelWidgets.next();
  if (childWidget instanceof RadioButton) {
    ...do stuff
  }
}

我倾向于不为其成员查询小部件。 根据你的例子,这与我对如何显示RadioButtons的决定联系在一起。 如果您稍后决定在FlexTable的单元格中显示单选按钮以控制垂直和水平排列,该怎么办? 要进行此更改意味着您的窗口小部件迭代器将无法工作。 FlexTable是Panel而不是ComplexPanel。 如果您决定使用FlexTable替换VerticalPanel,我上面编写的代码将无效。

如果要采取类似这种方法的东西,我会在某些Java Collection中保留我的相关小部件列表(如一组RadioButtons)。 我将该Collection传递给我的表示类,并在那里编写代码来进行布局。 通常这是一个UiBinder类,这些RadioButtons的“@UiField(provided = true)”。 然后,演示者中的代码将传入的Collection的RadioButton元素与UiBinder布局中的RadioButtons的UiField占位符相关联。 因此我的所有布局决策实际上都在UiBinder xml文件中。 如果我决定撕掉我的垂直面板并用FlexTable替换它,我可能不必触及一行Java代码,假设我把事情分开了。

[实际上,我可能会决定在表示层中使用RadioButtons,特别是在XML文件中。 该表示类将在EventBus上触发一条消息,指示用户已经通过RadioButton ValueChangeHandler进行了选择,我不在乎我是否在FlexPaable中的VerticalPanel或ToggleButtons中使用了RadioButtons。


A GWT VerticalPanel is a subclass of ComplexPanel, an abstract class for Panels that contain more than one child widget. In ComplexPanel (and so inherited by VerticalPanel) are methods for getting the number of child widgets, getting references to them by index, and so on. You could build an iterator something like this:

Iterator<Widget> vPanelWidgets = myVerticalPanel.iterator();
while (vPanelWidgets.hasNext()){
  Widget childWidget = vPanelWidgets.next();
  if (childWidget instanceof RadioButton) {
    ...do stuff
  }
}

I tend not to query a widget for its members. That ties me to the decisions I made about how to display the RadioButtons, following your example. What if you decide later to display your radio buttons in the cells of a FlexTable in order to control vertical and horizontal arrangement? To make that change means your widget iterator won't work. FlexTable is a Panel but not a ComplexPanel. The code I wrote above won't work if you decide to replace the VerticalPanel with a FlexTable.

If was to take something like this approach, I would keep my lists of related widgets (like a group of RadioButtons) in some sort of Java Collection. I pass that Collection to my presentation class, and inside there I write the code to do the layout. Usually that's a UiBinder class, with "@UiField(provided = true)" for these RadioButtons. The code in the presenter then associates the RadioButton elements of the Collection I passed in to the UiField placeholders for the RadioButtons in the UiBinder layout. So all my layout decisions are actually in the UiBinder xml file. If I decide to rip out my Vertical Panel and replace it with a FlexTable, I might not have to touch a single line of Java code, assuming I separated things out correctly.

[Actually, I would probably keep my decision to use RadioButtons inside the presentation layer, and inside the XML file in particular. That presentation class would fire a message on the EventBus to indicate the user had made a selection via a RadioButton ValueChangeHandler, and I wouldn't care if I used RadioButtons in a VerticalPanel or ToggleButtons in a FlexTable.]

相关问答

更多
  • GWT VerticalPanel是ComplexPanel的子类,ComplexPanel是包含多个子窗口小部件的Panel的抽象类。 在ComplexPanel中(由VerticalPanel继承)是获取子窗口小部件数量,通过索引获取对它们的引用等的方法。 你可以构建一个像这样的迭代器: Iterator vPanelWidgets = myVerticalPanel.iterator(); while (vPanelWidgets.hasNext()){ Widget childW ...
  • 您是否参考了ARIA的GWT指南文档 - https://developers.google.com/web-toolkit/doc/latest/DevGuideA11y 另请阅读http://code.google.com/p/google-web-toolkit/wiki/ARIAImplementationDetails 我不确定在DisclosurePanel中添加角色标记或aria标记。 您可以尝试遵循GWT团队用于Tree或Menubar的原则,类似地显示/隐藏交互数据。 Did you re ...
  • Roo的一个卖点是你可以轻松地从你的项目中删除它 。 Roo生成的代码中没有任何内容预先假定您将继续无限期地使用Roo。 GWT Expenses示例应用程序实际上是作为Roo生成的应用程序启动的,但已成为手动维护的代码库。 至于你的第一点,UiBinder并没有做任何你不能手工编写的事情。 您编写的所有声明性XML代码都将由UiBinder Generator转换为直接的过程代码。 要删除基于UiBinder的UI,只需删除.ui.xml文件和自定义UiBinder子接口。 One of the sell ...
  • 1)很多,如果您的模块增长相当大,只需简单地刷新前端(或在部署之前进行编译)可能非常耗时。 但是,您可以像往常一样使用Firebug或类似工具,更有趣的是,调试简单而强大。 然而,存在一些小问题,例如Java和基于Javascript的正则表达式之间的不兼容性。 2)更难以例如采用基于Photoshop等设计者提供的“预期屏幕样本”(不确定如何调用)并将其转换为基于html / js GWT的前端。 这是一个真正的缺点。 3)你需要知道你在做什么。 但确实有很多可用的。 使用GXT / SmartGWT或类 ...
  • 通过增加Eclipse本身的内存解决了这个问题。 在eclipse.ini文件中添加了以下内容。 -vmargs -Dosgi.requiredJavaVersion=1.5 -Dhelp.lucene.tokenizer=standard -XX:MaxPermSize=512m -Xms512m -Xmx1024m Resolved this issue by increasing the memory of Eclipse itself. Added following in eclipse.ini ...
  • MVP是Google为基础GWT小部件创建的模式,它不支持内置的数据绑定.Google从未说过MVP适用于SmartGWT小部件,其中小部件已经支持数据绑定,而我们(Isomorphic)强烈支持建议不要尝试将SmartMWT与Google MVP一起使用,除非您有非常特殊的,非常不寻常的需求(更多内容如下: SmartGWT GWT客户端服务器架构 ) 当人们尝试将MVP应用于SmartGWT时,我们看到他们重新创建SmartGWT中已存在的功能,使事情变得比他们需要的复杂得多,并且反复寻找不存在的API ...
  • 从SmartGWT快速入门指南开始。 我们强烈建议不要将MVP与SmartGWT一起使用,因为SmartGWT已经有了内置的数据绑定范例,我们认为它提供的代码要少得多。 因此,深入学习SmartGWT数据绑定方法,查看示例,尝试使用它,然后回到您一直在审查的令人困惑的材料,并问自己一个问题:它们是否简化了什么? 他们是否更容易添加我需要的功能? 如果没有,请不要打扰他们。 Start with the SmartGWT QuickStart Guide. We strongly recommend agai ...
  • 我会看看您的用户如何实际使用该网站。 如果你找到一个很好的GWT应用程序分离(每个用户都坚持自己的小GWT应用程序),那么我不明白为什么你不能分开它们。 但是,如果您发现您的用户经常从一个应用程序切换到另一个应用程序,并且会产生启动其他应用程序的开销,那么您可能需要考虑一个单一的应用程序。 我倾向于这种方法,除非你正在制作非常激烈的应用程序。 我怀疑浏览器在高度优化的JavaScript GWT推出时会遇到很多麻烦。 I would take a look at how your users actuall ...
  • 事件总线的目的是使事件处理更容易,是的,使代码更易读和易于管理。 我会回答这个问题,假设你的困境在于如何对事件进行分类。 GWTEvent类有一个source()方法。 这告诉你是谁解雇了这个事件。 如果这是不可接受的,那么您的事件中始终可以有一个“id”字段,由发件人填充。 因此,如果TreeView1正在触发事件,则事件的id将设置为“treeView1”。 当事件处理程序收到此事件时,它将检查id并决定是否处理该事件。 这样,您就可以为整个应用程序使用单个“God”事件处理程序。 The purpos ...
  • 就像在JavaScript中一样this.@myPackage.class_a::fireFoo(Ljava/lang/String;)是对方法的引用,但它当时并没有将该方法绑定到this对象。 方法内部的这个将在调用函数时确定, 而不是在检索引用的时间。 因此,你需要一个代表 : var that = this; $wnd.fireFoo = $entry(function(s) { that.@myPackage.class_a::fireFoo(Ljava/lang/String;)(s); }) ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)