---
title: "mJson"
description: "A minimal, zero-dependency, highly ergonomic JSON library for Java with schema validation and custom object mapping."
canonical_url: "https://www.kobrix.com/projects/mjson"
---
# mJson

> A minimal, zero-dependency, highly ergonomic JSON library for Java with schema validation and custom object mapping.

**mJson** is a lean, zero-dependency JSON library for Java packaged in a single source file (`Json.java`). It was born out of frustration with heavyweight, ceremony-ridden Java JSON libraries that force developers to juggle half a dozen classes (`JSONObject`, `JSONArray`, `JsonElement`, `JsonPrimitive`, `ObjectMapper`) just to read or construct a tree of data.

## Design Philosophy: One Unifying Concept

In **mJson**, every JSON entity—whether an object, an array, a string, a number, a boolean, or `null`—is represented by a single unifying class: **Json**.

- **Zero External Dependencies**: Drop a single class or tiny Maven artifact into any project.
- **Chainable, Declarative API**: Navigate, mutate, and construct deeply nested JSON structures fluently without boilerplate type-casting.
- **Parent Tracking & Graph Awareness**: Every `Json` node optionally tracks its enclosing parent, making tree traversal and transformation effortless.
- **Built-in JSON Schema Support**: Validate documents directly against JSON Schema specifications.

## Code Example

```java [Example.java]
import mjson.Json;
import static mjson.Json.*;

// Construct a composable content node cleanly
Json node = object()
    .set("id", "home-hero")
    .set("type", "hero_banner")
    .set("meta", object()
        .set("title", "Kobrix Software")
        .set("published", true))
    .set("tags", array("hypergraphdb", "mjson", "architecture"));

// Navigate without ceremony
String title = node.at("meta").at("title").asString();
boolean isPublished = node.at("meta").at("published").isTrue();

// Mutate in place and serialize
node.at("tags").add("r&d");
System.out.println(node.toString());
```

## Role in Composable Content & HyperGraphDB

Because `mJson` treats untyped, hierarchical data as a uniform recursive structure while interoperating seamlessly with Java types, it serves as the natural wire and document representation layer over **HyperGraphDB**—bridging web frontends and JSON APIs with deep hypergraph persistence.

---

- [GitHub Repository](https://github.com/bolerio/mjson)


## Sitemap

See the full [sitemap](https://www.kobrix.com/sitemap.md) for all pages.
