Skip to content

JSON->URL defines a text format for the JSON data model suitable for use within a URL/URI (as described by RFC3986). This repository holds the Java reference implementation of JSON->URL.

License

Notifications You must be signed in to change notification settings

jsonurl/jsonurl-java

JSON→URL

Apache License, Version 2.0, January 2004 Release javadoc GitHub Build Status Quality Gate Coverage Lines of Code Security Rating Vulnerabilities Maintainability Rating FOSSA Status Contributor Covenant Conventional Commits

json.org module: Known Vulnerabilities javadoc

javax.json module: Known Vulnerabilities javadoc

About

RFC8259 describes the JSON data model and interchange format, which is widely used in application-level protocols including RESTful APIs. It is common for applications to request resources via the HTTP POST method, with JSON entities. However, POST is suboptimal for requests which do not modify a resource's state. JSON→URL defines a text format for the JSON data model suitable for use within a URL/URI.

Usage

The factory artifact defines a generic JSON->URL parser and includes an implementation based Java SE data types (e.g. java.util.Map, java.util.List, etc). There are two additional modules, distributed as separate artifacts, which implement a parser based on JSR-374 and Douglas Crockford's Java API.

Java SE API example:

<dependencies>
  <dependency>
    <groupId>org.jsonurl</groupId>
    <artifactId>jsonurl-factory</artifactId>
    <version>${jsonurl.version}</version>
  </dependency>
</dependencies>
import java.util.Map;
import org.jsonurl.j2se.JsonUrlParser;

JsonUrlParser p = new JsonUrlParser();
Map obj = p.parseObject( "(Hello:World!)" );
System.out.println(obj.get("Hello")) // World!

Json.org example:

<dependencies>
  <dependency>
    <groupId>org.jsonurl</groupId>
    <artifactId>jsonurl-jsonorg</artifactId>
    <version>${jsonurl.version}</version>
  </dependency>
</dependencies>
import org.json.JSONObject;
import org.jsonurl.jsonorg.JsonUrlParser;

JsonUrlParser p = new JsonUrlParser();
JSONObject obj = p.parseObject( "(Hello:World!)" );
System.out.println(obj.get("Hello")) // World!

JSR-374 example:

<dependencies>
  <dependency>
    <groupId>org.jsonurl</groupId>
    <artifactId>jsonurl-jsr374</artifactId>
    <version>${jsonurl.version}</version>
  </dependency>
  <dependency>
    <groupId>org.glassfish</groupId>
    <artifactId>javax.json</artifactId>
    <version>${javax.json.version}</version>
  </dependency>
</dependencies>
import javax.json.JsonObject;
import org.jsonurl.jsonp.JsonUrlParser;

JsonUrlParser p = new JsonUrlParser();
JsonObject obj = p.parseObject( "(Hello:World!)" );
System.out.println(obj.get("Hello")) // World!

Javadocs

All artifacts published to Maven Central include sources and javadoc JARs. You can browse the current, and all previous revisions, via Javadoc.io:

Additionally, Javadocs are also generated automatically on pushes to main.

Security

The parser is designed to parse untrusted input. It supports limits on the number of parsed values and depth of nested arrays or objects. When the limit is exceeded a LimitException is thrown. Sane limit values are set by default.

License

FOSSA Status

About

JSON->URL defines a text format for the JSON data model suitable for use within a URL/URI (as described by RFC3986). This repository holds the Java reference implementation of JSON->URL.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published