Thrift、JSON 和 REST 之间的区别
有人可以告诉我 JSON、Thrift 和 REST 之间的区别吗? 如何决定使用哪一个? 哪一个是最快的?
Can somebody please tell me difference between JSON, Thrift and REST ?
How one can decide which one to use ?
Which one is the fastest one ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JSON 只是数据格式,您可以在各种情况下应用它,从在 NoSQL 数据库中存储数据,到 REST 调用中的参数编码
REST 是组织客户端-服务器的方式相互作用。 REST 的核心是资源,由其 ID 标识。 REST 服务器提供对该资源的操作,例如删除、更新等。REST 调用通常是无状态的,换句话说,服务器不保留任何客户端状态,但它从调用本身获取操作所需的所有信息。 REST 通常在 HTTP 之上提供,URI 用于编码资源 ID、操作和参数。此外,参数通常使用 JSON 进行编码。 REST 服务器通常构建在 HTTP 服务器之上,而客户端则使用一些 HTTP 客户端技术,例如curl。
Thrift 是轻量级二进制远程过程调用协议。在接口定义语言中,您定义操作以及它们所采用的参数的结构。 Thrift 编译器为客户端和服务器生成存根,以及将调用编组为二进制格式的代码。然后,该调用将根据 Thrift 传输之一通过线路进行传输。 Thrift 客户端和服务器可以用多种语言和技术来实现。
JSON is only data format, you can apply it in various situations, from storing data in NoSQL databases, to encoding of parameters in REST call
REST Is way of organizing client-server interaction. Central to the REST is resource, identified by its ID. REST server provides operations upon that resource, like deleting, updating, etc. REST calls are typically stateless, in another words, the server does not keep any client state, but it gets all information necessary for the operation from the call itself. REST is typically provided on top of HTTP, and URI- is used to encode resource id, operation and parameters. In addition parameters are often encoded with JSON. REST servers are usually built on top of HTTP servers, and clients use some HTTP client technology like curl.
Thrift is lightweight binary remote procedure call protocol. In interface definition langugage you define operations, and structure of parameters they take. Thrift compiler generates stubs for client and the server, and code to marshal calls into the binary format. That calls are then transfered over the wire according to one of the Thrift transports. Thrift clients and servers can be implemented in number of languages and technologies.