Skip to content

io microsphere json JSONException

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

JSONException

Type: Class | Module: microsphere-java-core | Package: io.microsphere.json

Source: microsphere-java-core/src/main/java/io/microsphere/json/JSONException.java

Overview

Thrown to indicate a problem with the JSON API. Such problems include:

  • Attempts to parse or construct malformed documents
  • Use of null as a name
  • Use of numeric types not available to JSON, such as Double#isNaN() NaNs or Double#isInfinite() infinities.
  • Lookups using an out of range index or nonexistent name
  • Type mismatches on lookups

Although this is a checked exception, it is rarely recoverable. Most callers should simply wrap this exception in an unchecked exception and rethrow:

public JSONArray toJSONObject() {
try {
JSONObject result = new JSONObject();
...
} catch (JSONException e) {
throw new RuntimeException(e);
}
}

Declaration

public class JSONException extends Exception

Version Information

  • Introduced in: 0.1.10-SNAPSHOT (current)
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.json.JSONException;

This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally