更好的是:Json或XML(PHP) [英] What's better: Json or XML (PHP)

查看:65
本文介绍了更好的是:Json或XML(PHP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用PHP处理少量数据,我可以在Json和XML之间进行选择.但是我不知道该选择什么,我从未与其中之一合作过.所以我想要最简单的一个.

I'm manipulating few data with PHP, I have the choice between Json and XML. But I don't know what to choose, I never worked with one of them. So I want the easiest one.

我还想知道是否有好的类可以使解析(XML或Json)更加容易.

Also I wonder if there's good classes that can make parsing (XML or Json) easier.

我主要关注易用性,而不是速度和规模.

I focus mainly on ease of use rather than speed and scale.

推荐答案

json.org 使JSON解析变得简单. SimpleXML 使PHP的XML变得简单.

json.org makes JSON parsing simple. SimpleXML makes XML simple for PHP.

选择哪个时,实际上取决于您的应用程序.如果您要将数据传递给JavaScript以在客户端进行处理,则建议使用JSON. IMO,XML非常适合系统之间的数据交换,因为它非常易于理解并且易于阅读(使您的解释更容易). JSON较小,因为没有结束标记.

When choosing which one, it really depends on your application. If you will be passing data to JavaScript for processing on the client-side, then I recommend JSON. IMO, XML is better for data interchange between systems because it is very well understood and human readable (making interpreting easier for you). JSON is smaller over the wire, as there are no closing tags.

这篇关于更好的是:Json或XML(PHP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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