Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eliasstar/jsonrpc4j
A general JSON-RPC 2.0 Wrapper for Java
https://github.com/eliasstar/jsonrpc4j
gson json-rpc maven
Last synced: 6 days ago
JSON representation
A general JSON-RPC 2.0 Wrapper for Java
- Host: GitHub
- URL: https://github.com/eliasstar/jsonrpc4j
- Owner: EliasStar
- License: lgpl-3.0
- Created: 2020-08-15T18:23:06.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-01-08T10:11:18.000Z (12 months ago)
- Last Synced: 2024-11-08T10:12:02.493Z (about 2 months ago)
- Topics: gson, json-rpc, maven
- Language: Java
- Homepage: https://eliasstar.github.io/JsonRpc4J/
- Size: 590 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: COPYING
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# JsonRpc4J
> A general JSON-RPC 2.0 Wrapper for Java## Downloads
### Jar
Releases can be downloaded [here](https://github.com/EliasStar/JsonRpc4J/releases).
The javadoc can be found in the "javadoc" suffix jar and the "sources" suffix jar includes the raw, uncompiled source code for reference.### Maven
#### pom.xml
Add the following under `project/repositories` tag:
```xmlgithub
JsonRpc4J GitHub Maven Packages
https://maven.pkg.github.com/EliasStar/JsonRpc4J```
Furthermore add the following under `project/dependencies` tag:
```xmleliasstar
json-rpc
VERSION```
Replace `VERSION` with a version found under releases, preferably the latest.#### settings.xml
Is located under `~/.m2/settings.xml`.
Add the following under `settings/servers` tag:
```xmlgithub
YOUR_USERNAME
YOUR_PERSONAL_ACCESS_TOKEN```
Be sure to replace `YOUR_USERNAME` and `YOUR_PERSONAL_ACCESS_TOKEN`.## Usage
### Get a connection
```java
// Simple
var con = JsonRpc.connect("https://example.com/jsonrpc.do");
```
```java
// Customizable
var client = HttpClient.newHttpClient();
var gson = new Gson();var con = new ConnectionBuilder(client, "https://example.com/jsonrpc.do").setGson(gson).build();
```### Make a request
```java
// Remote procedure call
var result = con.callRemoteProcedure("exampleMethod");
```
```java
// With parameters
var params = new JsonArray();params.add("foo");
params.add(42);var result = con.callRemoteProcedure("exampleMethod", params);
```
```java
// Notification
con.sendNotification("exampleNotification");
``````java
// Batch request
var results = con.sendBatchRequest(
new Request(0, "firstMethod"),
new Request(1, "secondMethod"),
new Notification("exampleNotification")
);
```## License
JsonRpc4J - A general JSON-RPC 2.0 Wrapper for Java
Copyright (C) 2020-2021 Elias*This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see .