Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

JsonRpc4J

A general JSON-RPC 2.0 Wrapper for Java

Downloads

Jar

Releases can be downloaded here. 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:

<repository>
    <id>github</id>
    <name>JsonRpc4J GitHub Maven Packages</name>
    <url>https://maven.pkg.github.com/EliasStar/JsonRpc4J</url>
</repository>

Furthermore add the following under project/dependencies tag:

<dependency>
    <groupId>eliasstar</groupId>
    <artifactId>json-rpc</artifactId>
    <version>VERSION</version>
</dependency>

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:

<server>
    <id>github</id>
    <username>YOUR_USERNAME</username>
    <password>YOUR_PERSONAL_ACCESS_TOKEN</password>
</server>

Be sure to replace YOUR_USERNAME and YOUR_PERSONAL_ACCESS_TOKEN.

Usage

Get a connection

// Simple
var con = JsonRpc.connect("https://example.com/jsonrpc.do");
// 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

// Remote procedure call
var result = con.callRemoteProcedure("exampleMethod");
// With parameters
var params = new JsonArray();

params.add("foo");
params.add(42);

var result = con.callRemoteProcedure("exampleMethod", params);
// Notification
con.sendNotification("exampleNotification");
// 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 https://www.gnu.org/licenses/.

About

A general JSON-RPC 2.0 Wrapper for Java

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages