Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tejainece/json_rpc_client
Dart library for JSON RPC 1 and JSON RPC 2
https://github.com/tejainece/json_rpc_client
Last synced: about 2 months ago
JSON representation
Dart library for JSON RPC 1 and JSON RPC 2
- Host: GitHub
- URL: https://github.com/tejainece/json_rpc_client
- Owner: tejainece
- License: bsd-3-clause
- Created: 2021-08-16T06:49:09.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-08-18T00:53:12.000Z (over 3 years ago)
- Last Synced: 2023-08-20T22:28:55.684Z (over 1 year ago)
- Language: Dart
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# json_rpc_client
A very simple Dart library to write JSON RPC v1 and v2 clients.
# Features
+ Supports both V1 and V2
+ Supports Basic auth for JSON RPC over HTTP# Example
```dart
import 'package:json_rpc_client/json_rpc_client.dart';Future main() async {
// Create a JSON RPC HTTP client
final client = JRPCHttpClient(Uri.parse('http://localhost:8080/rpc'));// Make a JSON RPC v1 call
final resp1 = await client.callRPCv1(
JRPC1Request(id: client.nextId, method: 'examplev1', params: [1, 2]));
print('error: ${resp1.error} result: ${resp1.result}');// Make a JSON RPC v2 call
final resp2 = await client.callRPCv2(JRPC2Request(
id: client.nextId,
method: 'examplev2',
params: {'param1': 'hello', 'param2': 10}));
print('error: ${resp1.error} result: ${resp1.result}');
}
```