将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获得组件(Gwt get Components)

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

如何在GWT 2.4中使用WAI-ARIA(How to use WAI-ARIA in GWT 2.4)

您是否参考了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 y...

SpringROO + GWT定制(SpringROO+GWT customization)

Roo的一个卖点是你可以轻松地从你的项目中删除它 。 Roo生成的代码中没有任何内容预先假定您将继续无限期地使用Roo。 GWT Expenses示例应用程序实际上是作为Roo生成的应用程序启动的,但已成为手动维护的代码库。 至于你的第一点,UiBinder并没有做任何你不能手工编写的事情。 您编写的所有声明性XML代码都将由UiBinder Generator转换为直接的过程代码。 要删除基于UiBinder的UI,只需删除.ui.xml文件和自定义UiBinder子接口。 One of the...

从HTML / JS迁移到GWT(Moving from HTML/JS to GWT)

1)很多,如果您的模块增长相当大,只需简单地刷新前端(或在部署之前进行编译)可能非常耗时。 但是,您可以像往常一样使用Firebug或类似工具,更有趣的是,调试简单而强大。 然而,存在一些小问题,例如Java和基于Javascript的正则表达式之间的不兼容性。 2)更难以例如采用基于Photoshop等设计者提供的“预期屏幕样本”(不确定如何调用)并将其转换为基于html / js GWT的前端。 这是一个真正的缺点。 3)你需要知道你在做什么。 但确实有很多可用的。 使用GXT / Smart...

在“验证GWT组件”期间发生内部错误。(An internal error occurred during: “Validating GWT components”. GC overhead limit exceeded)

通过增加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 eclips...

GWT MVP和SmartGWT兼容性(GWT MVP and SmartGWT compatibility)

MVP是Google为基础GWT小部件创建的模式,它不支持内置的数据绑定.Google从未说过MVP适用于SmartGWT小部件,其中小部件已经支持数据绑定,而我们(Isomorphic)强烈支持建议不要尝试将SmartMWT与Google MVP一起使用,除非您有非常特殊的,非常不寻常的需求(更多内容如下: SmartGWT GWT客户端服务器架构 ) 当人们尝试将MVP应用于SmartGWT时,我们看到他们重新创建SmartGWT中已存在的功能,使事情变得比他们需要的复杂得多,并且反复寻找不存...

GWT mvp:Places,RequestFactory和SmartGwt以及gwt-sl(GWT mvp : Places , RequestFactory and SmartGwt and gwt-sl)

从SmartGWT快速入门指南开始。 我们强烈建议不要将MVP与SmartGWT一起使用,因为SmartGWT已经有了内置的数据绑定范例,我们认为它提供的代码要少得多。 因此,深入学习SmartGWT数据绑定方法,查看示例,尝试使用它,然后回到您一直在审查的令人困惑的材料,并问自己一个问题:它们是否简化了什么? 他们是否更容易添加我需要的功能? 如果没有,请不要打扰他们。 Start with the SmartGWT QuickStart Guide. We strongly recommend...

GWT网页的复杂性(GWT web page complexity)

我会看看您的用户如何实际使用该网站。 如果你找到一个很好的GWT应用程序分离(每个用户都坚持自己的小GWT应用程序),那么我不明白为什么你不能分开它们。 但是,如果您发现您的用户经常从一个应用程序切换到另一个应用程序,并且会产生启动其他应用程序的开销,那么您可能需要考虑一个单一的应用程序。 我倾向于这种方法,除非你正在制作非常激烈的应用程序。 我怀疑浏览器在高度优化的JavaScript GWT推出时会遇到很多麻烦。 I would take a look at how your users ac...

将EventBus与GWT组件一起使用的最佳实践(best practice to use EventBus with GWT components)

事件总线的目的是使事件处理更容易,是的,使代码更易读和易于管理。 我会回答这个问题,假设你的困境在于如何对事件进行分类。 GWTEvent类有一个source()方法。 这告诉你是谁解雇了这个事件。 如果这是不可接受的,那么您的事件中始终可以有一个“id”字段,由发件人填充。 因此,如果TreeView1正在触发事件,则事件的id将设置为“treeView1”。 当事件处理程序收到此事件时,它将检查id并决定是否处理该事件。 这样,您就可以为整个应用程序使用单个“God”事件处理程序。 The p...

GWT JSNI方法曝光(GWT JSNI method exposure)

就像在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...

相关文章

更多

net.sf.json解析json对象

JSON-lib包是一个beans,collections,maps,java arrays 和XML ...

让Solr返回JSON数据

http://localhost:1985/solr/select/?q=*%3A*&amp;vers ...

数组数据 与json 的转换``

我用的是hibernate +struts &lt;% dtreeBS treebs= new d ...

Json.Net学习笔记

Json.Net学习笔记(十四) JSON的部分序列化 通常当用到大的Json文档的时 ...

怎么递归json嵌套json?

比如JSONObject: {&quot;temp1&quot;:{&quot;b&quot;:&q ...

JSON是什么?

JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。易于人阅 ...

请教关于spring mvc中使用json-lib-ext-spring返回json的问题

我做了一个这样的框架: spring+hibernate+spring mvc 想让spring ...

XStream处理JSON

XStream_WORKSPACE\com656463\xstream.

最新问答

更多

您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)

将diff文件复制到存储库的根目录,然后执行以下操作: git apply yourcoworkers.diff 有关apply命令的更多信息, apply 见其手册页 。 顺便说一下:一个更好的方法是通过文件交换整个提交文件是发送者上的命令git format-patch ,然后在接收器上加上git am ,因为它也传送作者信息和提交信息。 如果修补程序应用程序失败,并且生成diff的提交实际上在您的备份中,则可以使用尝试在更改中合并的apply程序的-3选项。 它还适用于Unix管道,如下

将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)

尝试将第二行更改为snprintf(buf1, sizeof buf1, "%.2f", balance1); 。 另外,为什么要声明用该特定表达式分配缓冲区的存储量? EDIT @LưuVĩnhPhúc在下面的评论中提到我的原始答案中的格式说明符将舍入而不是截断,因此根据如何在不使用C舍入的情况下截断小数,您可以执行以下操作: float balance = 200.56866; int tmp = balance1 * 100; float balance1 = tmp / 100.0; c

OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)

这是简单的解决方案 在你需要写的控制器中 BackendMenu::setContext('Archetypics.Team', 'website', 'team'); 请参阅https://octobercms.com/docs/backend/controllers-views-ajax#navigation-context BackendMenu::setContext('Author.Plugin name', 'Menu code', 'Sub menu code'); 你需要在r

页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)

每当发出请求时ASP都会创建一个新的Page对象,并且一旦它将响应发送回用户就不会保留对该Page对象的引用,因此只要你找不到某种方法来保持生命自己引用该Page对象后,一旦发送响应, Page和只能通过该页面访问的所有对象才有资格进行垃圾回收。 ASP creates a new Page object whenever a request is made, and it does not hold onto the reference to that Page object once it

codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)

要在生产服务器中调试这个,你可以临时放 error_reporting(E_ALL); 并查看有哪些其他错误阻止正确的重定向。 您还应该检查生产服务器发送的响应标头。 它是否具有“缓存”,是否需要重新验证标头等 to debug this in production server, you can temporary put error_reporting(E_ALL); and see what other errors are there that prevents the proper

在计算机拍照在哪里进入

打开娥的电脑.在下面找到视频设备点击进去就可以了...

使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)

你是对的。 第一次输入后,换行符将保留在输入缓冲区中。 第一次读取后尝试插入: cin.ignore(); // to ignore the newline character 或者更好的是: //discards all input in the standard input stream up to and including the first newline. cin.ignore(numeric_limits::max(), '\n'); 您必须为#inc

No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)

for (int k = 0; k > 10; k++) { System.out.println(k); } k不大于10,所以循环将永远不会执行。 我想要什么是k<10 ,不是吗? for (int k = 0; k < 10; k++) { System.out.println(k); } for (int k = 0; k > 10; k++) { System.out.println(k); } k is not greater than 10, so loop

单页应用程序:页面重新加载(Single Page Application: page reload)

优点是不注销会避免惹恼用户,以至于他们会想要杀死你:-)。 说真的,如果每次刷新页面时应用程序都会将我注销(或者在新选项卡中打开一个链接),我再也不会使用该应用程序了。 好吧,不要这样做。 确保身份验证令牌存储在刷新后的某个位置,即不在某些JS变量中,而是存储在cookie或本地存储中。 The advantage is that not logging off will avoid pissing off your users so much that they'll want to kill

在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)

EXECUTE IMMEDIATE 'SELECT '||field_val_temp ||' FROM tableb WHERE function_id = :func_val AND rec_key = :rec_key' INTO field_val USING 'STDCUSAC' , yu.rec_key; 和, EXECUTE IMMEDIATE 'UPDATE tablec SET field_val_'||i||' = :field_val' USI