SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Downloaden Sie, um offline zu lesen
© Peter R. Egli 2015
1/11
Rev. 1.60
JSON-RPC indigoo.com
Peter R. Egli
INDIGOO.COM
JSON-RPC
JSON REMOTE PROCEDURE CALL
OVERVIEW OF JSON-RPC, A VERY SIMPLE AND
LIGHTWEIGHT RPC PROTOCOL
FOR DISTRIBUTED APPLICATIONS
© Peter R. Egli 2015
2/11
Rev. 1.60
JSON-RPC indigoo.com
Contents
1. What is JSON-RPC?
2. JSON-RPC interactions
3. Transport options for JSON-RPC
4. JSON serialization format
5. JSON-RPC 2.0 examples
6. When to use JSON-RPC
© Peter R. Egli 2015
3/11
Rev. 1.60
JSON-RPC indigoo.com
1. What is JSON-RPC?
JSON-RPC is a simple RPC mechanism, similar to XML-RPC.
Protocol:
Unlike XML-RPC which is a client-server protocol, JSON-RPC is a peer-to-peer protocol.
It uses JSON (Javascript Object Notation, RFC4627) as the serialization format and plain TCP
streams or HTTP as transport mechanism.
JSON message types:
JSON-RPC defines 3 message types:
Request:
Method invokation with arguments encoded in JSON.
Response:
Reply to method invokation containing the return argument encoded in JSON.
Notification:
Asynchronous request without response.
Specification:
JSON-RPC is very simple, i.e. the JSON-RPC specification is very short (ca. 5 pages).
See http://json-rpc.org/.
© Peter R. Egli 2015
4/11
Rev. 1.60
JSON-RPC indigoo.com
2. JSON-RPC interactions
JSON-RPC defines 2 message exchange patterns that support most of the usual peer2peer
interaction schemes.
A. Request-Response:
The sending JSON peer invokes a method on the remote JSON peer with a JSON request.
The remote peer sends back a JSON response message.
B. Notification:
The sending peer sends a single notification message. There is no response message.
JSON peer
Request (REQ)
Response (RSP)
method
params
id
Method to be invoked.
Request message:
Arguments to be passed to method as an array of objects.
Request ID to match request and response.
result
error
id
Object returned by the called method.
Response message:
Error object if an error occurred.
Request ID to match request and response.
Notification (NOT)
method
params
id
Method to be invoked.
Notification message:
Arguments to be passed to method as an array of objects.
Must be null (nothing to match).
JSON peer
JSON peer JSON peer
© Peter R. Egli 2015
5/11
Rev. 1.60
JSON-RPC indigoo.com
3. Transport options for JSON-RPC (1/2)
JSON does not require a specific transport protocol.
The JSON-RPC standard defines 2 transport protocols for conveying JSON messages.
A. TCP stream (default transport):
The JSON-RPC default transport is a simple TCP stream (JSON-RPC exchanges serialized
objects over plain TCP sockets).
JSON
-RPC
peer
JSON
-RPC
peer
REQ1NOT1
RSP1 REQ2 NOT2
RSP2
TCP stream connection
(2 unidirectional connections)
© Peter R. Egli 2015
6/11
Rev. 1.60
JSON-RPC indigoo.com
3. Transport options for JSON-RPC (2/2)
B. HTTP connection:
Here an HTTP connection is used as a transport channel.
The HTTP-request is used as transport container for JSON-request (REQ), JSON-responses
(RSP) and JSON-notification (NOT) messages that are sent from the JSON-peer with the HTTP
client. Likewise the HTTP-response is used for transporting JSON-messages from the JSON-
peer with the HTTP server.
N.B.: There is no mapping of JSON request to HTTP-request. HTTP is merely the transport
mechanism.
The HTTP client and server will need to use a long polling scheme so the server always has a
response ready to use for a RSP, REQ or NOT message.
HTTP
client
JSON
-RPC
peer
HTTP
server
REQ1NOT1
JSON
-RPC
peer
NOT1REQ1
HTTP GET request
REQ1NOT1
RSP1 REQ2 NOT2RSP1 REQ2NOT2
HTTP response
RSP1 REQ2 NOT2
RSP2 RSP2
HTTP POST request
RSP2
© Peter R. Egli 2015
7/11
Rev. 1.60
JSON-RPC indigoo.com
4. JSON serialization format (1/2)
JSON (Javascript Object Notation, RFC4627) is a lightweight, text-based, language-independent
data exchange format. JSON text is a sequence of tokens.
JSON types:
1. Primitive types:
string Sequence of 0..n Unicode characters, enclosed in quotation marks.
Example: „hello world“
number Numerical value (represention as used in most programming languages).
Examples: 3.45, 5E3
boolean true / false value
null Null value (= no object or no value)
2. Structured types:
Array Ordered sequence of 0..n values.
Example: [1,3,4]
Object Unordered collection of 0..n name:value pairs.
Name = string
Value = string, number, boolean, null, object, array.
Example: {"jsonrpc": "2.0", "method": "update", "params": [1,2,3,4,5]}
Encoding:
JSON text is encoded in Unicode. The default encoding is UTF-8.
© Peter R. Egli 2015
8/11
Rev. 1.60
JSON-RPC indigoo.com
4. JSON serialization format (2/2)
JSON grammar expressed in ABNF (excerpt only, ABNF syntax see RFC5234):
JSON-text = object / array;
begin-array = ws %x5B ws ; [ left square bracket
begin-object = ws %x7B ws ; { left curly bracket
end-array = ws %x5D ws ; ] right square bracket
end-object = ws %x7D ws ; } right curly bracket
name-separator = ws %x3A ws ; : colon
value-separator = ws %x2C ws ; , comma
whitespace = *{%x20 / %x09 / %x0A / %X0d)
value = false / null / true / object / array / number / string
false = %x66.61.6c.73.65 ; false
null = %x6e.75.6c.6c ; null
true = %x74.72.75.65 ; true
object = begin-object [ member *( value-separator member ) ] end-object
member = string name-separator value
array = begin-array [ value *( value-separator value ) ] end-array
number = [ minus ] int [ frac ] [ exp ]
string = quotation-mark *char quotation-mark
© Peter R. Egli 2015
9/11
Rev. 1.60
JSON-RPC indigoo.com
5. JSON-RPC 2.0 examples (1/2)
Notation:
--> Data sent to JSON service
<-- Data coming from JSON service
RPC call with parameters:
--> {"jsonrpc": "2.0", "method": "subtract", "params": [84, 42], "id": 1}
<-- {"jsonrpc": "2.0", "result": 42, "id": 1}
RPC call with named parameters:
--> {"jsonrpc": "2.0", "method": "subtract", "params": {"subtrahend": 42, "minuend":
84}, "id": 3}
<-- {"jsonrpc": "2.0", "result": 42, "id": 3}
Notification:
--> {"jsonrpc": "2.0", "method": "update", "params": [1,2,3,4,5]}
RPC call with invalid JSON:
--> {"jsonrpc": "2.0", "method": "foobar, "params": "bar", "baz]
<-- {"jsonrpc": "2.0", "error": {"code": -12345, "message": "Parse error."}, "id": null}
© Peter R. Egli 2015
10/11
Rev. 1.60
JSON-RPC indigoo.com
5. JSON-RPC 2.0 examples (2/2)
RPC call batch (multiple JSON requests mapped to one JSON packet):
--> [
{"jsonrpc": "2.0", "method": "sum", "params": [1,2,4], "id": "1"},
{"jsonrpc": "2.0", "method": "notify_hello", "params": [7]},
{"jsonrpc": "2.0", "method": "subtract", "params": [42,23], "id": "2"},
{"foo": "boo"},
{"jsonrpc": "2.0", "method": "foo.get", "params": {"name": "myself"}, "id": "5"},
{"jsonrpc": "2.0", "method": "get_data", "id": "9"}
]
© Peter R. Egli 2015
11/11
Rev. 1.60
JSON-RPC indigoo.com
6. When to use JSON-RPC
Applicability:
JSON-RPC is well suited for web service applications with the need for bidirectional interaction
(peer2peer), but where the complexity of SOAP is not required.
Example 1:
Remote management of devices over the Internet. SNMP (Simple Network Management
Protocol) would be the standard management protocol, but it is difficult to get through the
Internet due to the presence of firewalls.
Example 2:
Web application where the web server needs to update the client (server push).
JSON-RPC, as its name implies, was derived from Javascript. The client side of the application
is usually Javascript based (e.g. AJAX).

Weitere Àhnliche Inhalte

Was ist angesagt?

Exploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on KubernetesExploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on KubernetesRed Hat Developers
 
OpenId Connect Protocol
OpenId Connect ProtocolOpenId Connect Protocol
OpenId Connect ProtocolMichael Furman
 
gRPC Overview
gRPC OverviewgRPC Overview
gRPC OverviewVarun Talwar
 
Building secure applications with keycloak
Building secure applications with keycloak Building secure applications with keycloak
Building secure applications with keycloak Abhishek Koserwal
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and responseSahil Agarwal
 
gRPC and Microservices
gRPC and MicroservicesgRPC and Microservices
gRPC and MicroservicesJonathan Gomez
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetesrajdeep
 
Api gateway in microservices
Api gateway in microservicesApi gateway in microservices
Api gateway in microservicesKunal Hire
 
REST vs gRPC: Battle of API's
REST vs gRPC: Battle of API'sREST vs gRPC: Battle of API's
REST vs gRPC: Battle of API'sLuram Archanjo
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC StructureDipika Wadhvani
 
Docker Networking Deep Dive
Docker Networking Deep DiveDocker Networking Deep Dive
Docker Networking Deep DiveDocker, Inc.
 
[MeetUp][1st] ì˜€ëŠŹëŽ…ìŽì˜_ìż ëČ„ë„€í‹°ìŠ€_넀튞워í‚č
[MeetUp][1st] ì˜€ëŠŹëŽ…ìŽì˜_ìż ëČ„ë„€í‹°ìŠ€_넀튞워í‚č[MeetUp][1st] ì˜€ëŠŹëŽ…ìŽì˜_ìż ëČ„ë„€í‹°ìŠ€_넀튞워í‚č
[MeetUp][1st] ì˜€ëŠŹëŽ…ìŽì˜_ìż ëČ„ë„€í‹°ìŠ€_넀튞워í‚čInfraEngineer
 
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
 Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t... Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...AboutYouGmbH
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in GoAlmog Baku
 
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes Down
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes DownDebugging Your Debugging Tools: What to do When Your Service Mesh Goes Down
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes DownAspen Mesh
 
Cilium + Istio with Gloo Mesh
Cilium + Istio with Gloo MeshCilium + Istio with Gloo Mesh
Cilium + Istio with Gloo MeshChristian Posta
 

Was ist angesagt? (20)

Exploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on KubernetesExploring the power of OpenTelemetry on Kubernetes
Exploring the power of OpenTelemetry on Kubernetes
 
OpenId Connect Protocol
OpenId Connect ProtocolOpenId Connect Protocol
OpenId Connect Protocol
 
gRPC Overview
gRPC OverviewgRPC Overview
gRPC Overview
 
Building secure applications with keycloak
Building secure applications with keycloak Building secure applications with keycloak
Building secure applications with keycloak
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
 
gRPC and Microservices
gRPC and MicroservicesgRPC and Microservices
gRPC and Microservices
 
Introduction to Kubernetes
Introduction to KubernetesIntroduction to Kubernetes
Introduction to Kubernetes
 
Api gateway in microservices
Api gateway in microservicesApi gateway in microservices
Api gateway in microservices
 
REST vs gRPC: Battle of API's
REST vs gRPC: Battle of API'sREST vs gRPC: Battle of API's
REST vs gRPC: Battle of API's
 
02 api gateway
02 api gateway02 api gateway
02 api gateway
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
Introduction to gRPC
Introduction to gRPCIntroduction to gRPC
Introduction to gRPC
 
Docker Networking Deep Dive
Docker Networking Deep DiveDocker Networking Deep Dive
Docker Networking Deep Dive
 
[MeetUp][1st] ì˜€ëŠŹëŽ…ìŽì˜_ìż ëČ„ë„€í‹°ìŠ€_넀튞워í‚č
[MeetUp][1st] ì˜€ëŠŹëŽ…ìŽì˜_ìż ëČ„ë„€í‹°ìŠ€_넀튞워í‚č[MeetUp][1st] ì˜€ëŠŹëŽ…ìŽì˜_ìż ëČ„ë„€í‹°ìŠ€_넀튞워í‚č
[MeetUp][1st] ì˜€ëŠŹëŽ…ìŽì˜_ìż ëČ„ë„€í‹°ìŠ€_넀튞워í‚č
 
Log4j in 8 slides
Log4j in 8 slidesLog4j in 8 slides
Log4j in 8 slides
 
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
 Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t... Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
Robert Kubis - gRPC - boilerplate to high-performance scalable APIs - code.t...
 
gRPC in Go
gRPC in GogRPC in Go
gRPC in Go
 
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes Down
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes DownDebugging Your Debugging Tools: What to do When Your Service Mesh Goes Down
Debugging Your Debugging Tools: What to do When Your Service Mesh Goes Down
 
GRPC.pptx
GRPC.pptxGRPC.pptx
GRPC.pptx
 
Cilium + Istio with Gloo Mesh
Cilium + Istio with Gloo MeshCilium + Istio with Gloo Mesh
Cilium + Istio with Gloo Mesh
 

Andere mochten auch

Java and the blockchain - introducing web3j
Java and the blockchain - introducing web3jJava and the blockchain - introducing web3j
Java and the blockchain - introducing web3jConor Svensson
 
Using RabbitMQ and Netty library to implement RPC protocol
Using RabbitMQ and Netty library to implement RPC protocolUsing RabbitMQ and Netty library to implement RPC protocol
Using RabbitMQ and Netty library to implement RPC protocolTho Q Luong Luong
 
Blockchain - Navigating this Game-Changing Technology
Blockchain - Navigating this Game-Changing TechnologyBlockchain - Navigating this Game-Changing Technology
Blockchain - Navigating this Game-Changing TechnologyConor Svensson
 
Netflix at-disney-09-26-2014
Netflix at-disney-09-26-2014Netflix at-disney-09-26-2014
Netflix at-disney-09-26-2014Monal Daxini
 
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)Peter Lubbers
 
Blockchain Coding Dojo - BlockchainHub Graz
Blockchain Coding Dojo - BlockchainHub GrazBlockchain Coding Dojo - BlockchainHub Graz
Blockchain Coding Dojo - BlockchainHub GrazBlockchainHub Graz
 
ì‚ŹëĄ€ëĄœ ëłž ëȘšë°”음 ì›č/앱 Ʞ획, 제작 êłŒì • 및 íŹìžíŠž
ì‚ŹëĄ€ëĄœ ëłž ëȘšë°”음 ì›č/앱 Ʞ획, 제작 êłŒì • 및 íŹìžíŠžì‚ŹëĄ€ëĄœ ëłž ëȘšë°”음 ì›č/앱 Ʞ획, 제작 êłŒì • 및 íŹìžíŠž
ì‚ŹëĄ€ëĄœ ëłž ëȘšë°”음 ì›č/앱 Ʞ획, 제작 êłŒì • 및 íŹìžíŠžmosaicnet
 
ëȘšë°”음 서ëč„슀 Ʞ획 시작하Ʞ
ëȘšë°”음 서ëč„슀 Ʞ획 시작하ꞰëȘšë°”음 서ëč„슀 Ʞ획 시작하Ʞ
ëȘšë°”음 서ëč„슀 Ʞ획 시작하ꞰJae-hyung Park
 
REST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesEberhard Wolff
 
Ʞ획서 템플멿
Ʞ획서 í…œí”ŒëŠżêž°íšì„œ 템플멿
Ʞ획서 템플멿Jaewon Choi
 
제음Ʞ획 읎마튞 Ʞ획서
제음Ʞ획 읎마튞 Ʞ획서제음Ʞ획 읎마튞 Ʞ획서
제음Ʞ획 읎마튞 Ʞ획서Yerim An
 

Andere mochten auch (11)

Java and the blockchain - introducing web3j
Java and the blockchain - introducing web3jJava and the blockchain - introducing web3j
Java and the blockchain - introducing web3j
 
Using RabbitMQ and Netty library to implement RPC protocol
Using RabbitMQ and Netty library to implement RPC protocolUsing RabbitMQ and Netty library to implement RPC protocol
Using RabbitMQ and Netty library to implement RPC protocol
 
Blockchain - Navigating this Game-Changing Technology
Blockchain - Navigating this Game-Changing TechnologyBlockchain - Navigating this Game-Changing Technology
Blockchain - Navigating this Game-Changing Technology
 
Netflix at-disney-09-26-2014
Netflix at-disney-09-26-2014Netflix at-disney-09-26-2014
Netflix at-disney-09-26-2014
 
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
 
Blockchain Coding Dojo - BlockchainHub Graz
Blockchain Coding Dojo - BlockchainHub GrazBlockchain Coding Dojo - BlockchainHub Graz
Blockchain Coding Dojo - BlockchainHub Graz
 
ì‚ŹëĄ€ëĄœ ëłž ëȘšë°”음 ì›č/앱 Ʞ획, 제작 êłŒì • 및 íŹìžíŠž
ì‚ŹëĄ€ëĄœ ëłž ëȘšë°”음 ì›č/앱 Ʞ획, 제작 êłŒì • 및 íŹìžíŠžì‚ŹëĄ€ëĄœ ëłž ëȘšë°”음 ì›č/앱 Ʞ획, 제작 êłŒì • 및 íŹìžíŠž
ì‚ŹëĄ€ëĄœ ëłž ëȘšë°”음 ì›č/앱 Ʞ획, 제작 êłŒì • 및 íŹìžíŠž
 
ëȘšë°”음 서ëč„슀 Ʞ획 시작하Ʞ
ëȘšë°”음 서ëč„슀 Ʞ획 시작하ꞰëȘšë°”음 서ëč„슀 Ʞ획 시작하Ʞ
ëȘšë°”음 서ëč„슀 Ʞ획 시작하Ʞ
 
REST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For Microservices
 
Ʞ획서 템플멿
Ʞ획서 í…œí”ŒëŠżêž°íšì„œ 템플멿
Ʞ획서 템플멿
 
제음Ʞ획 읎마튞 Ʞ획서
제음Ʞ획 읎마튞 Ʞ획서제음Ʞ획 읎마튞 Ʞ획서
제음Ʞ획 읎마튞 Ʞ획서
 

Ähnlich wie JSON-RPC - JSON Remote Procedure Call

Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Mihai Iachimovschi
 
Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)Viktor Turskyi
 
Blockchain Meetup- Introduction to dApps and the steps involved to create a d...
Blockchain Meetup- Introduction to dApps and the steps involved to create a d...Blockchain Meetup- Introduction to dApps and the steps involved to create a d...
Blockchain Meetup- Introduction to dApps and the steps involved to create a d...Techracers
 
Sun RPC (Remote Procedure Call)
Sun RPC (Remote Procedure Call)Sun RPC (Remote Procedure Call)
Sun RPC (Remote Procedure Call)Peter R. Egli
 
Consuming RESTful Web services in PHP
Consuming RESTful Web services in PHPConsuming RESTful Web services in PHP
Consuming RESTful Web services in PHPZoran Jeremic
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHPZoran Jeremic
 
XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)Kiran Jonnalagadda
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCTim Burks
 
Use perl creating web services with xml rpc
Use perl creating web services with xml rpcUse perl creating web services with xml rpc
Use perl creating web services with xml rpcJohnny Pork
 
Week4 lec1-bscs1
Week4 lec1-bscs1Week4 lec1-bscs1
Week4 lec1-bscs1syedhaiderraza
 
Everybody Polyglot! - Cross-Language RPC with Erlang
Everybody Polyglot! - Cross-Language RPC with ErlangEverybody Polyglot! - Cross-Language RPC with Erlang
Everybody Polyglot! - Cross-Language RPC with ErlangRusty Klophaus
 
Cap'n Proto (C++ Developer Meetup Iasi)
Cap'n Proto (C++ Developer Meetup Iasi)Cap'n Proto (C++ Developer Meetup Iasi)
Cap'n Proto (C++ Developer Meetup Iasi)Ovidiu Farauanu
 
[Reactive] Programming with [Rx]ROS
[Reactive] Programming with [Rx]ROS[Reactive] Programming with [Rx]ROS
[Reactive] Programming with [Rx]ROSAndrzej Wasowski
 
Robot operating systems (ros) overview & (1)
Robot operating systems (ros) overview & (1)Robot operating systems (ros) overview & (1)
Robot operating systems (ros) overview & (1)Piyush Chand
 
Robot Operating Systems (Ros) Overview &amp; (1)
Robot Operating Systems (Ros) Overview &amp; (1)Robot Operating Systems (Ros) Overview &amp; (1)
Robot Operating Systems (Ros) Overview &amp; (1)Piyush Chand
 
Communication Protocols And Web Services
Communication Protocols And Web ServicesCommunication Protocols And Web Services
Communication Protocols And Web ServicesOmer Katz
 
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...PROIDEA
 
Claire protorpc
Claire protorpcClaire protorpc
Claire protorpcFan Robbin
 

Ähnlich wie JSON-RPC - JSON Remote Procedure Call (20)

Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.Teach your (micro)services talk Protocol Buffers with gRPC.
Teach your (micro)services talk Protocol Buffers with gRPC.
 
Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)Yet another json rpc library (mole rpc)
Yet another json rpc library (mole rpc)
 
Blockchain Meetup- Introduction to dApps and the steps involved to create a d...
Blockchain Meetup- Introduction to dApps and the steps involved to create a d...Blockchain Meetup- Introduction to dApps and the steps involved to create a d...
Blockchain Meetup- Introduction to dApps and the steps involved to create a d...
 
Sun RPC (Remote Procedure Call)
Sun RPC (Remote Procedure Call)Sun RPC (Remote Procedure Call)
Sun RPC (Remote Procedure Call)
 
Consuming RESTful Web services in PHP
Consuming RESTful Web services in PHPConsuming RESTful Web services in PHP
Consuming RESTful Web services in PHP
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
 
Day01 api
Day01   apiDay01   api
Day01 api
 
XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)
 
Fast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPCFast and Reliable Swift APIs with gRPC
Fast and Reliable Swift APIs with gRPC
 
Use perl creating web services with xml rpc
Use perl creating web services with xml rpcUse perl creating web services with xml rpc
Use perl creating web services with xml rpc
 
Json
JsonJson
Json
 
Week4 lec1-bscs1
Week4 lec1-bscs1Week4 lec1-bscs1
Week4 lec1-bscs1
 
Everybody Polyglot! - Cross-Language RPC with Erlang
Everybody Polyglot! - Cross-Language RPC with ErlangEverybody Polyglot! - Cross-Language RPC with Erlang
Everybody Polyglot! - Cross-Language RPC with Erlang
 
Cap'n Proto (C++ Developer Meetup Iasi)
Cap'n Proto (C++ Developer Meetup Iasi)Cap'n Proto (C++ Developer Meetup Iasi)
Cap'n Proto (C++ Developer Meetup Iasi)
 
[Reactive] Programming with [Rx]ROS
[Reactive] Programming with [Rx]ROS[Reactive] Programming with [Rx]ROS
[Reactive] Programming with [Rx]ROS
 
Robot operating systems (ros) overview & (1)
Robot operating systems (ros) overview & (1)Robot operating systems (ros) overview & (1)
Robot operating systems (ros) overview & (1)
 
Robot Operating Systems (Ros) Overview &amp; (1)
Robot Operating Systems (Ros) Overview &amp; (1)Robot Operating Systems (Ros) Overview &amp; (1)
Robot Operating Systems (Ros) Overview &amp; (1)
 
Communication Protocols And Web Services
Communication Protocols And Web ServicesCommunication Protocols And Web Services
Communication Protocols And Web Services
 
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejƛć w programowa...
 
Claire protorpc
Claire protorpcClaire protorpc
Claire protorpc
 

Mehr von Peter R. Egli

LPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M ScenariosLPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M ScenariosPeter R. Egli
 
Data Networking Concepts
Data Networking ConceptsData Networking Concepts
Data Networking ConceptsPeter R. Egli
 
Communication middleware
Communication middlewareCommunication middleware
Communication middlewarePeter R. Egli
 
Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)Peter R. Egli
 
Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)Peter R. Egli
 
Microsoft .NET Platform
Microsoft .NET PlatformMicrosoft .NET Platform
Microsoft .NET PlatformPeter R. Egli
 
Overview of Cloud Computing
Overview of Cloud ComputingOverview of Cloud Computing
Overview of Cloud ComputingPeter R. Egli
 
MQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message QueueingMQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message QueueingPeter R. Egli
 
Enterprise Application Integration Technologies
Enterprise Application Integration TechnologiesEnterprise Application Integration Technologies
Enterprise Application Integration TechnologiesPeter R. Egli
 
Overview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyOverview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyPeter R. Egli
 
Android Native Development Kit
Android Native Development KitAndroid Native Development Kit
Android Native Development KitPeter R. Egli
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Peter R. Egli
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Peter R. Egli
 
Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)Peter R. Egli
 
MSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingMSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingPeter R. Egli
 
Common Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBACommon Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBAPeter R. Egli
 
Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Peter R. Egli
 
JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging ServicePeter R. Egli
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Peter R. Egli
 

Mehr von Peter R. Egli (20)

LPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M ScenariosLPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
LPWAN Technologies for Internet of Things (IoT) and M2M Scenarios
 
Data Networking Concepts
Data Networking ConceptsData Networking Concepts
Data Networking Concepts
 
Communication middleware
Communication middlewareCommunication middleware
Communication middleware
 
Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)Transaction Processing Monitors (TPM)
Transaction Processing Monitors (TPM)
 
Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)Business Process Model and Notation (BPMN)
Business Process Model and Notation (BPMN)
 
Microsoft .NET Platform
Microsoft .NET PlatformMicrosoft .NET Platform
Microsoft .NET Platform
 
Overview of Cloud Computing
Overview of Cloud ComputingOverview of Cloud Computing
Overview of Cloud Computing
 
MQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message QueueingMQTT - MQ Telemetry Transport for Message Queueing
MQTT - MQ Telemetry Transport for Message Queueing
 
Enterprise Application Integration Technologies
Enterprise Application Integration TechnologiesEnterprise Application Integration Technologies
Enterprise Application Integration Technologies
 
Overview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technologyOverview of Microsoft .Net Remoting technology
Overview of Microsoft .Net Remoting technology
 
Android Native Development Kit
Android Native Development KitAndroid Native Development Kit
Android Native Development Kit
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)
 
Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)Overview of SCTP (Stream Control Transmission Protocol)
Overview of SCTP (Stream Control Transmission Protocol)
 
Web services
Web servicesWeb services
Web services
 
Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)Overview of Spanning Tree Protocol (STP & RSTP)
Overview of Spanning Tree Protocol (STP & RSTP)
 
MSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message QueueingMSMQ - Microsoft Message Queueing
MSMQ - Microsoft Message Queueing
 
Common Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBACommon Object Request Broker Architecture - CORBA
Common Object Request Broker Architecture - CORBA
 
Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)Component Object Model (COM, DCOM, COM+)
Component Object Model (COM, DCOM, COM+)
 
JMS - Java Messaging Service
JMS - Java Messaging ServiceJMS - Java Messaging Service
JMS - Java Messaging Service
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)
 

KĂŒrzlich hochgeladen

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĂșjo
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

KĂŒrzlich hochgeladen (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

JSON-RPC - JSON Remote Procedure Call

  • 1. © Peter R. Egli 2015 1/11 Rev. 1.60 JSON-RPC indigoo.com Peter R. Egli INDIGOO.COM JSON-RPC JSON REMOTE PROCEDURE CALL OVERVIEW OF JSON-RPC, A VERY SIMPLE AND LIGHTWEIGHT RPC PROTOCOL FOR DISTRIBUTED APPLICATIONS
  • 2. © Peter R. Egli 2015 2/11 Rev. 1.60 JSON-RPC indigoo.com Contents 1. What is JSON-RPC? 2. JSON-RPC interactions 3. Transport options for JSON-RPC 4. JSON serialization format 5. JSON-RPC 2.0 examples 6. When to use JSON-RPC
  • 3. © Peter R. Egli 2015 3/11 Rev. 1.60 JSON-RPC indigoo.com 1. What is JSON-RPC? JSON-RPC is a simple RPC mechanism, similar to XML-RPC. Protocol: Unlike XML-RPC which is a client-server protocol, JSON-RPC is a peer-to-peer protocol. It uses JSON (Javascript Object Notation, RFC4627) as the serialization format and plain TCP streams or HTTP as transport mechanism. JSON message types: JSON-RPC defines 3 message types: Request: Method invokation with arguments encoded in JSON. Response: Reply to method invokation containing the return argument encoded in JSON. Notification: Asynchronous request without response. Specification: JSON-RPC is very simple, i.e. the JSON-RPC specification is very short (ca. 5 pages). See http://json-rpc.org/.
  • 4. © Peter R. Egli 2015 4/11 Rev. 1.60 JSON-RPC indigoo.com 2. JSON-RPC interactions JSON-RPC defines 2 message exchange patterns that support most of the usual peer2peer interaction schemes. A. Request-Response: The sending JSON peer invokes a method on the remote JSON peer with a JSON request. The remote peer sends back a JSON response message. B. Notification: The sending peer sends a single notification message. There is no response message. JSON peer Request (REQ) Response (RSP) method params id Method to be invoked. Request message: Arguments to be passed to method as an array of objects. Request ID to match request and response. result error id Object returned by the called method. Response message: Error object if an error occurred. Request ID to match request and response. Notification (NOT) method params id Method to be invoked. Notification message: Arguments to be passed to method as an array of objects. Must be null (nothing to match). JSON peer JSON peer JSON peer
  • 5. © Peter R. Egli 2015 5/11 Rev. 1.60 JSON-RPC indigoo.com 3. Transport options for JSON-RPC (1/2) JSON does not require a specific transport protocol. The JSON-RPC standard defines 2 transport protocols for conveying JSON messages. A. TCP stream (default transport): The JSON-RPC default transport is a simple TCP stream (JSON-RPC exchanges serialized objects over plain TCP sockets). JSON -RPC peer JSON -RPC peer REQ1NOT1 RSP1 REQ2 NOT2 RSP2 TCP stream connection (2 unidirectional connections)
  • 6. © Peter R. Egli 2015 6/11 Rev. 1.60 JSON-RPC indigoo.com 3. Transport options for JSON-RPC (2/2) B. HTTP connection: Here an HTTP connection is used as a transport channel. The HTTP-request is used as transport container for JSON-request (REQ), JSON-responses (RSP) and JSON-notification (NOT) messages that are sent from the JSON-peer with the HTTP client. Likewise the HTTP-response is used for transporting JSON-messages from the JSON- peer with the HTTP server. N.B.: There is no mapping of JSON request to HTTP-request. HTTP is merely the transport mechanism. The HTTP client and server will need to use a long polling scheme so the server always has a response ready to use for a RSP, REQ or NOT message. HTTP client JSON -RPC peer HTTP server REQ1NOT1 JSON -RPC peer NOT1REQ1 HTTP GET request REQ1NOT1 RSP1 REQ2 NOT2RSP1 REQ2NOT2 HTTP response RSP1 REQ2 NOT2 RSP2 RSP2 HTTP POST request RSP2
  • 7. © Peter R. Egli 2015 7/11 Rev. 1.60 JSON-RPC indigoo.com 4. JSON serialization format (1/2) JSON (Javascript Object Notation, RFC4627) is a lightweight, text-based, language-independent data exchange format. JSON text is a sequence of tokens. JSON types: 1. Primitive types: string Sequence of 0..n Unicode characters, enclosed in quotation marks. Example: „hello world“ number Numerical value (represention as used in most programming languages). Examples: 3.45, 5E3 boolean true / false value null Null value (= no object or no value) 2. Structured types: Array Ordered sequence of 0..n values. Example: [1,3,4] Object Unordered collection of 0..n name:value pairs. Name = string Value = string, number, boolean, null, object, array. Example: {"jsonrpc": "2.0", "method": "update", "params": [1,2,3,4,5]} Encoding: JSON text is encoded in Unicode. The default encoding is UTF-8.
  • 8. © Peter R. Egli 2015 8/11 Rev. 1.60 JSON-RPC indigoo.com 4. JSON serialization format (2/2) JSON grammar expressed in ABNF (excerpt only, ABNF syntax see RFC5234): JSON-text = object / array; begin-array = ws %x5B ws ; [ left square bracket begin-object = ws %x7B ws ; { left curly bracket end-array = ws %x5D ws ; ] right square bracket end-object = ws %x7D ws ; } right curly bracket name-separator = ws %x3A ws ; : colon value-separator = ws %x2C ws ; , comma whitespace = *{%x20 / %x09 / %x0A / %X0d) value = false / null / true / object / array / number / string false = %x66.61.6c.73.65 ; false null = %x6e.75.6c.6c ; null true = %x74.72.75.65 ; true object = begin-object [ member *( value-separator member ) ] end-object member = string name-separator value array = begin-array [ value *( value-separator value ) ] end-array number = [ minus ] int [ frac ] [ exp ] string = quotation-mark *char quotation-mark
  • 9. © Peter R. Egli 2015 9/11 Rev. 1.60 JSON-RPC indigoo.com 5. JSON-RPC 2.0 examples (1/2) Notation: --> Data sent to JSON service <-- Data coming from JSON service RPC call with parameters: --> {"jsonrpc": "2.0", "method": "subtract", "params": [84, 42], "id": 1} <-- {"jsonrpc": "2.0", "result": 42, "id": 1} RPC call with named parameters: --> {"jsonrpc": "2.0", "method": "subtract", "params": {"subtrahend": 42, "minuend": 84}, "id": 3} <-- {"jsonrpc": "2.0", "result": 42, "id": 3} Notification: --> {"jsonrpc": "2.0", "method": "update", "params": [1,2,3,4,5]} RPC call with invalid JSON: --> {"jsonrpc": "2.0", "method": "foobar, "params": "bar", "baz] <-- {"jsonrpc": "2.0", "error": {"code": -12345, "message": "Parse error."}, "id": null}
  • 10. © Peter R. Egli 2015 10/11 Rev. 1.60 JSON-RPC indigoo.com 5. JSON-RPC 2.0 examples (2/2) RPC call batch (multiple JSON requests mapped to one JSON packet): --> [ {"jsonrpc": "2.0", "method": "sum", "params": [1,2,4], "id": "1"}, {"jsonrpc": "2.0", "method": "notify_hello", "params": [7]}, {"jsonrpc": "2.0", "method": "subtract", "params": [42,23], "id": "2"}, {"foo": "boo"}, {"jsonrpc": "2.0", "method": "foo.get", "params": {"name": "myself"}, "id": "5"}, {"jsonrpc": "2.0", "method": "get_data", "id": "9"} ]
  • 11. © Peter R. Egli 2015 11/11 Rev. 1.60 JSON-RPC indigoo.com 6. When to use JSON-RPC Applicability: JSON-RPC is well suited for web service applications with the need for bidirectional interaction (peer2peer), but where the complexity of SOAP is not required. Example 1: Remote management of devices over the Internet. SNMP (Simple Network Management Protocol) would be the standard management protocol, but it is difficult to get through the Internet due to the presence of firewalls. Example 2: Web application where the web server needs to update the client (server push). JSON-RPC, as its name implies, was derived from Javascript. The client side of the application is usually Javascript based (e.g. AJAX).