XML,JSON还是什么? [英] XML, JSON, or what?

查看:80
本文介绍了XML,JSON还是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


我正在编写一个多用户会计/业务应用程序,它使用

套接字在服务器和客户端之间进行通信。服务器包含

所有业务逻辑。它没有客户的直接知识。我已经设计了一个简单的消息格式来交换

两者之间的信息。


起初,我使用XML作为消息格式。然后我读了一篇文章,建议不要使用XML for Python-to-Python,所以我把它改成了一个派对的Python对象的b
。它的工作原理也一样。


目前客户端使用wxPython。我的中期目标之一是

写一个基于Web的客户端。我不认为现在我所拥有的所有功能都很容易复制

但我希望能够接近。

我没有做过任何严肃的事情研究但是我很确定我会在客户端上使用javascript来使它成为通用的。


理想情况下,服务器应该是能够处理wxPython客户端或web

客户端,甚至不知道它正在与哪个客户交谈。显然我

不能使用Pickle。所以我的问题是,使用什么样的理想格式

?我可以回到XML,或者我可以切换到JSON - 我已经阅读了有关它的
,它看起来并不复杂。我的消息不是非常大(到目前为止,复杂的屏幕布局最大约2k)所以我

不要认为性能会成为一个问题。


我宁愿现在做出决定,否则我将在稍后进行很多改变。有没有人有任何建议?


谢谢


Frank Millman

Hi all

I am writing a multi-user accounting/business application, which uses
sockets to communicate between server and client. The server contains
all the business logic. It has no direct knowledge of the client. I
have devised a simple message format to exchange information between
the two.

At first, I used XML as a message format. Then I read the article that
recommended not using XML for Python-to-Python, so I changed it to a
pickled collection of Python objects. It works just as well.

At present the client uses wxPython. One of my medium-term goals is to
write a web-based client. I don''t think it will be easy to reproduce
all the functionality that I have at present, but I hope to get close.
I have not done any serious research yet, but I am pretty sure I will
use javascript on the client, to make it as universal as possible.

Ideally, the server should be able to handle a wxPython client or a web
client, without even knowing which one it is talking to. Obviously I
cannot use Pickle for this. So my question is, what is the ideal format
to use? I could go back to XML, or I could switch to JSON - I have read
a bit about it and it does not seem complicated. My messages are not
very large (maximum about 2k so far for a complex screen layout) so I
don''t think performance will be an issue.

I would rather make a decision now, otherwise I will have a lot of
changes to make later on. Does anyone have any recommendations?

Thanks

Frank Millman

推荐答案

2006-06-08,Frank Millman< fr *** @ chagford.com>写道:
On 2006-06-08, Frank Millman <fr***@chagford.com> wrote:
我宁愿现在做出决定,否则我将在稍后进行很多改动。有没有人有任何建议?
I would rather make a decision now, otherwise I will have a lot of
changes to make later on. Does anyone have any recommendations?




您是否考虑过XMPP?

使用XMPP,您可以在服务器和客户端之间创建XML流。 />
XMPP是一个开放标准(由IETF提供)。

Jabber(jabber.org)基于XMPP标准。他们为各种数据交换开发协议。\\ b
XMPP。目前,它主要用于聊天,

但我们在内部使用它作为发布/订阅来控制一些机器。

他们做了很多关于scalabilty的思考,隐私,身份验证以及所有

当你在互联网上提供某些服务时你需要做的其他事情。


他们也有使用协议的协议GUI交互式(很像向导
$ * $ b $ Win * do,你得到一页要决定的东西,你按''next'',你得到

下一页等等。


Albert



Did you consider XMPP?
With XMPP you create XML streams between your server and the client.
XMPP is an open standard (by the IETF).

Jabber (jabber.org) is based on the XMPP standard. They develop protocols on
XMPP for all kinds of data exchange. Currently, it is mainly used for chatting,
but we use it in-house as publish/subscribe to control some machines too.
They do a lot of thinking about scalabilty, privacy, authentication, and all
that other stuff you need to do when you put some service on the internet.

They also have protocols for using a GUI interactively (much like the wizards
of Win* do, you get one page of things to decide, you press ''next'', you get the
next page, etc).

Albert


>用吗?我可以回到XML,或者我可以切换到JSON - 我已经阅读了


如果数据结构很简单,我会支持JSON。 XML相对来说是一个很难处理的问题,使用JSON你可以只需eval(*)
只需eval()数据就可以获得一个Python字典了

处理。


我最近使用JSON作为将数据从Java后端传递到

网页以供Javascript处理的方法,增加的副作用

我的Python测试脚本也可以轻松读取相同的数据。

> to use? I could go back to XML, or I could switch to JSON - I have read

I''d favour JSON if the data structures are simple personally. XML is
comparatively speaking a pain to deal with, where with JSON you can
simply eval() the data and you have a Python dictionary at your
disposal.

I recently used JSON as a way of passing data from a Java backend to a
web page for Javascript to deal with, with the added side effect that
my Python testing scripts could also easily read the same data.


[Frank Millman]
[Frank Millman]
我正在编写一个多用户会计/业务应用程序,它使用
套接字在服务器和客户端之间进行通信。服务器包含所有业务逻辑。它没有客户的直接知识。我已经设计了一种简单的消息格式来交换两者之间的信息。

首先,我使用XML作为消息格式。然后我读了那篇建议不要使用Python for Python-to-Python的文章,所以我把它改成了一个腌制的Python对象集合。它的工作原理也一样。


如果您只是将python与python进行通信,我会推荐Pyro,

,因为它具有所有套接字管理等,已经处理好了。

http://pyro.sourceforge.net

目前客户端使用wxPython。我的中期目标之一是编写基于Web的客户端。我不认为重现目前我所拥有的所有功能都很容易,但我希望能够接近。
我还没有做过任何认真的研究,但我很确定我将在客户端上使用javascript,使其尽可能通用。


如果你要混合使用javascript客户端和python服务器,那么你肯定需要跨平台的东西,比如XML或JSON。

理想情况下,服务器应该能够处理wxPython客户端或web
客户端,甚至不知道它正在与哪个客户端进行通信。显然我不能用Pickle来做这件事。所以我的问题是,使用什么样的理想格式?我可以回到XML,或者我可以切换到JSON - 我已经阅读了一些关于它的内容并且看起来并不复杂。


JSON确实(大部分)看起来很简单:它很适合你的需要

。你应该快速启动它。

我的消息不是很大(到目前为止,对于复杂的屏幕布局,最大约2k)所以我不会不认为表演会成为一个问题。


解析JSON几乎肯定比解析XML更快。你/ b $ b应该能够轻松解析数百甚至数千条2K JSON

的消息。在大多数语言中,JSON生成和解析至少与XML一样支持和健壮。

我宁愿现在做出决定,否则我会有很多
以后的变化。有没有人有任何建议?
I am writing a multi-user accounting/business application, which uses
sockets to communicate between server and client. The server contains
all the business logic. It has no direct knowledge of the client. I
have devised a simple message format to exchange information between
the two.

At first, I used XML as a message format. Then I read the article that
recommended not using XML for Python-to-Python, so I changed it to a
pickled collection of Python objects. It works just as well.
If you were just communicating python to python, I''d recommend Pyro,
since it has all the socket management, etc, already taken care of.

http://pyro.sourceforge.net
At present the client uses wxPython. One of my medium-term goals is to
write a web-based client. I don''t think it will be easy to reproduce
all the functionality that I have at present, but I hope to get close.
I have not done any serious research yet, but I am pretty sure I will
use javascript on the client, to make it as universal as possible.
If you''re going to mix javascript client and python server, you
definitely need something cross platform, like XML or JSON.
Ideally, the server should be able to handle a wxPython client or a web
client, without even knowing which one it is talking to. Obviously I
cannot use Pickle for this. So my question is, what is the ideal format
to use? I could go back to XML, or I could switch to JSON - I have read
a bit about it and it does not seem complicated.
JSON is indeed (mostly) as simple as it looks: it fits your need very
well. And you should be up and running with it very quickly.
My messages are not
very large (maximum about 2k so far for a complex screen layout) so I
don''t think performance will be an issue.
And parsing JSON will almost certainly be faster than parsing XML. You
should easily be able to parse hundreds or maybe thousands of 2K JSON
messages a second. And JSON generation and parsing is at least as well
supported and robust as XML, in most languages.
I would rather make a decision now, otherwise I will have a lot of
changes to make later on. Does anyone have any recommendations?




为了简单和便携,我会选择JSON。如果您有任何特定问题,请询问。


问候,


-

alan kennedy

----------------------------------- -------------------

电子邮件alan: http://xhaus.com/contact/alan



I''d go with JSON, for simplicity and portability. If you have any
specific questions about it, ask.

regards,

--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan


这篇关于XML,JSON还是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆