I was looking for JSON schema standards and their corresponding php implementations. Expecting some open source out there and I was surprised, to find only one php implementation. I was about using this technology (JSON) and the schema lib to parse my incoming browser requests.

This natural parse/validate activity seems natural in XML and make me wonder why this is not the case in JSON.

I end up with a doubt situation. Should I pursue my JSON structure data exchange or switch to XML?我第一次 Select JSON是因为它比XML简单,语法也不那么冗长,但如果我必须重新开发世界上所有现有的标准,这些论点就会变得更轻松.我还 Select 了JSON,希望限制我的web服务器和移动应用程序之间的通信规模.通过使用comet应用程序,XMPP似乎被谷歌、Facebook等大牌公司实现并用于实时聊天文本或基于视频的消息.

So the actual questions are:

  1. Is JSON for the poor web server developer that wants to know what happen on its traffic, and focus on over simplicity (do not be mistaken, here, I include myself)?
  2. IETF为JSON模式起草的草案是否是一项严肃的工作,因为服务器端(PHP)上几乎没有实现?
  3. Am I missing something, or maybe, the best communication pattern is to send data in xml to the server and expect a json response (many json schema implementation exist in javascript)?
  4. Or did I only faced the actual proof, that this concern has not been well served by the developer community because web developer using JSON do not test deeply their incoming request data?

请帮我理解一下,我在这里错过了一些经验吗?

推荐答案

这种自然的解析/验证活动在XML中似乎很自然,让我想知道为什么在JSON中不是这样.

Remember what made JSON famous: web applications with a very rich user interface written in JavaScript. JSON was perfect for that because data from the server mapped directly on JavaScript objects; hit a GET URL with Ajax and get back an object, no need for parsing or anything else.

Those rich interfaces made JavaScript a very popular language and JSON obviously rode along and it's popularity made it become the best candidate to overthrow "the angle bracket".

But XML has a long history behind it. It's a mature technology with lots of accompanying specifications. JSON is just catching up to those.

Although the draft specification expired in May 2011, the JSON Schema supporters think they have reached a pretty close to final version of the spec. So who knows what the future has in hold for JSON Schema.

I was surprised, to find only one php implementation [...] Does IETF draft for JSON schema is a serious work, since only few implementation exist on the server side (PHP) ?

Does this PHP implementation validate JSON as per the last version of the JSON Schema draft? If yes, is there a need for other implementations? Do you need lots of implementations to certify a specification is serious? That's just as saying that XSLT 2.0 is not serious because Microsoft didn't bother to implement it.

As for your last question, incoming data needs to be validated. You don't take a user request and throw it to the server and "hope it sticks". You validate it; and JSON Schema is not the only way to validate JSON data, so don't assume that web developers using JSON do not deeply test their incoming request data.

In conclusion, what I'm trying to say is that JSON can't fully replace XML, or the other way around. So use each technology where appropriate.

Json相关问答推荐

使用jolt删除空对象

将数组中的值作为键连接到另一个数组中的值(Jolt)

通过在织女星简化图上裁剪来显示文本

JOLT转换以基于对象属性过滤JSON数组

Jolt - 如何比较 if else 条件的两个值

如何将属性拆分为嵌套的JSON内容?

使用jq根据对象中键的值查找对象

将=分隔值文件转换为:json文件

Vue 3如何将参数作为json发送到axios get

使用 json_query 过滤嵌套列表中的元素

Microsoft GRAPH 查询使用端点 /deviceManagement/deviceHealthScripts 列出了一种不熟悉的检测脚本内容格式

获取json中某个键的索引

Laravel5 Json 获取文件内容

通过 RestAssured 中的 JsonPath 访问匿名数组的元素

PostgreSQL 中的 JSON 模式验证?

Protocol Buffer vs Json - 何时 Select 一个而不是另一个

js 中奇怪的 JSON 解析行为,Unexpected token :

Java HashMap 与 JSONObject

如何在所有子项中查询具有特定值的属性的firebase

无法将 System.String 转换或转换为 Class 对象