SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
© 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).

Contenu connexe

Tendances

Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with PythonLarry Cai
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
Jpa 잘 (하는 척) 하기
Jpa 잘 (하는 척) 하기Jpa 잘 (하는 척) 하기
Jpa 잘 (하는 척) 하기경원 이
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developersPatrick Savalle
 
Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLEmanuele Della Valle
 
php and sapi and zendengine2 and...
php and sapi and zendengine2 and...php and sapi and zendengine2 and...
php and sapi and zendengine2 and...do_aki
 
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...Fermin Galan
 
Les dessous du framework spring
Les dessous du framework springLes dessous du framework spring
Les dessous du framework springAntoine Rey
 
객체지향 개념 (쫌 아는체 하기)
객체지향 개념 (쫌 아는체 하기)객체지향 개념 (쫌 아는체 하기)
객체지향 개념 (쫌 아는체 하기)Seung-June Lee
 
Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)Fabien Gandon
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot IntroductionJeevesh Pandey
 
Introduction à spring boot
Introduction à spring bootIntroduction à spring boot
Introduction à spring bootAntoine Rey
 
Ksug2015 - JPA3, JPA 내부구조
Ksug2015 - JPA3, JPA 내부구조Ksug2015 - JPA3, JPA 내부구조
Ksug2015 - JPA3, JPA 내부구조Younghan Kim
 
[162] jpa와 모던 자바 데이터 저장 기술
[162] jpa와 모던 자바 데이터 저장 기술[162] jpa와 모던 자바 데이터 저장 기술
[162] jpa와 모던 자바 데이터 저장 기술NAVER D2
 
Initiation à Express js
Initiation à Express jsInitiation à Express js
Initiation à Express jsAbdoulaye Dieng
 

Tendances (20)

Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
ResourceSync Tutorial
ResourceSync TutorialResourceSync Tutorial
ResourceSync Tutorial
 
Jpa 잘 (하는 척) 하기
Jpa 잘 (하는 척) 하기Jpa 잘 (하는 척) 하기
Jpa 잘 (하는 척) 하기
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
Express JS
Express JSExpress JS
Express JS
 
Emertxe : Training portfolio
Emertxe : Training portfolioEmertxe : Training portfolio
Emertxe : Training portfolio
 
Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQL
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
php and sapi and zendengine2 and...
php and sapi and zendengine2 and...php and sapi and zendengine2 and...
php and sapi and zendengine2 and...
 
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...
Orion Context Broker NGSI-v2 Overview for Developers That Already Know NGSI-v...
 
Les dessous du framework spring
Les dessous du framework springLes dessous du framework spring
Les dessous du framework spring
 
Serving ML easily with FastAPI - meme version
Serving ML easily with FastAPI - meme versionServing ML easily with FastAPI - meme version
Serving ML easily with FastAPI - meme version
 
객체지향 개념 (쫌 아는체 하기)
객체지향 개념 (쫌 아는체 하기)객체지향 개념 (쫌 아는체 하기)
객체지향 개념 (쫌 아는체 하기)
 
Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)Ontology In A Nutshell (version 2)
Ontology In A Nutshell (version 2)
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Introduction à spring boot
Introduction à spring bootIntroduction à spring boot
Introduction à spring boot
 
Ksug2015 - JPA3, JPA 내부구조
Ksug2015 - JPA3, JPA 내부구조Ksug2015 - JPA3, JPA 내부구조
Ksug2015 - JPA3, JPA 내부구조
 
[162] jpa와 모던 자바 데이터 저장 기술
[162] jpa와 모던 자바 데이터 저장 기술[162] jpa와 모던 자바 데이터 저장 기술
[162] jpa와 모던 자바 데이터 저장 기술
 
Initiation à Express js
Initiation à Express jsInitiation à Express js
Initiation à Express js
 

En vedette

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
 

En vedette (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
 
기획서 템플릿
기획서 템플릿기획서 템플릿
기획서 템플릿
 
제일기획 이마트 기획서
제일기획 이마트 기획서제일기획 이마트 기획서
제일기획 이마트 기획서
 

Similaire à 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
 
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
 
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
 
gRPC and Microservices
gRPC and MicroservicesgRPC and Microservices
gRPC and MicroservicesJonathan Gomez
 
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
 

Similaire à 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)
 
gRPC and Microservices
gRPC and MicroservicesgRPC and Microservices
gRPC and Microservices
 
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...
 

Plus de 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
 

Plus de 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)
 

Dernier

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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
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
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Dernier (20)

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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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?
 
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
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced 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...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

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).