Built-in JSON, XML & Markdown

Parse, generate, and manipulate JSON, XML, and Markdown with native OorianCore support.

JSON Objects

JsonObject class for key-value data. Easy creation, access, and modification. Built into OorianCore.

JSON Arrays

JsonArray class for ordered collections. Iterate, add, remove with familiar methods. Built into OorianCore.

XML Support

Parse, create, traverse, and modify XML documents. Built into OorianCore.

Markdown Support

Convert Markdown to native Oorian HTML elements. No JavaScript, no template engines—pure Java.

Jsonable Interface

Implement Jsonable to make your classes automatically serializable to and from JSON.

No External Dependencies

All three libraries are built into OorianCore—no Jackson, Gson, JAXB, or CommonMark needed.

JSON API

Create and manipulate JSON with simple, intuitive methods. JsonObject, JsonArray, and Jsonable are all built into OorianCore—no add-on required.

Java
// Create a JSON object
JsonObject user = new JsonObject();
user.put("name", "John Doe");
user.put("email", "john@example.com");
user.put("age", 30);
user.put("active", true);

// Create nested objects
JsonObject address = new JsonObject();
address.put("street", "123 Main St");
address.put("city", "Springfield");
user.put("address", address);

// Create arrays
JsonArray roles = new JsonArray();
roles.add("admin");
roles.add("editor");
user.put("roles", roles);

// Access values
String name = user.getAsString("name");
int age = user.getAsInt("age");
boolean active = user.getAsBoolean("active");
JsonObject addr = user.getAsJsonObject("address");

// Parse from string
String jsonString = "{\"name\":\"Jane\",\"age\":25}";
JsonObject parsed = JsonObject.parse(jsonString);

// Convert to string
String output = user.toString();

XML API

XmlDocument and XmlElement classes for parsing, creating, and modifying XML—built right into OorianCore alongside the JSON API.

Java
// Parse XML from a string
String xml = "<users><user name='John'/><user name='Jane'/></users>";
XmlDocument doc = XmlDocument.parse(xml);

// Navigate the document
XmlElement root = doc.getRoot();
List<XmlElement> users = root.getElementsByTagName("user");

for (XmlElement user : users)
{
    String name = user.getAttribute("name");
    System.out.println("User: " + name);
}

// Load XML from a file or stream
XmlDocument config = XmlDocument.loadFromFile("/path/to/config.xml");
// XmlDocument config = XmlDocument.loadFromStream(inputStream);

// Create XML programmatically
XmlElement configRoot = new XmlElement("config");

XmlElement database = new XmlElement("database");
database.addAttribute("type", "postgresql");
configRoot.addElement(database);

XmlElement host = new XmlElement("host");
host.setText("localhost");
database.addElement(host);

XmlElement port = new XmlElement("port");
port.setText("5432");
database.addElement(port);

XmlDocument newDoc = new XmlDocument(configRoot);

// Save to file or convert to string
newDoc.saveToFile("/path/to/output.xml");
String xmlOutput = newDoc.toXmlString();

Markdown API

MarkdownParser converts Markdown text into native Oorian HTML elements—Div, H1, P, Table, Code, and more. No JavaScript rendering, no template engines. The output is a standard Oorian element tree that you can style, modify, and compose just like any other component.

Java
// Parse a full Markdown document into a Div
String markdown = \"""
    # Welcome to Oorian

    Oorian is a **server-side Java** web framework.

    ## Features

    - Pure Java development
    - No JavaScript required
    - 169 extensions & add-ons

    ```java
    @Page("/hello")
    public class HelloPage extends HtmlPage { }
    ```

    | Feature   | Status    |
    |-----------|-----------|
    | JSON      | Built-in  |
    | XML       | Built-in  |
    | Markdown  | Built-in  |
    \""";
Div rendered = MarkdownParser.parse(markdown);
body.addElement(rendered);
// Produces: H1, P (with Strong), H2, Ul with Li items,
// Pre > Code block, and a Table — all native Oorian elements

// Parse into individual elements (useful for selective insertion)
List<Element> elements = MarkdownParser.parseToElements(markdown);
for (Element el : elements)
{
    container.addElement(el);
}

// Parse inline Markdown into a Span (for bold, italic, links, code)
Span inline = MarkdownParser.parseInline("Visit **Oorian** at [oorian.com](https://oorian.com)");
paragraph.addElement(inline);

The Jsonable Interface

Implement Jsonable to make your model classes automatically serializable to JSON. Jsonable is built into OorianCore alongside the JSON API.

Java
public class Product implements Jsonable
{
    private String id;
    private String name;
    private double price;
    private boolean inStock;

    // Getters and setters...

    @Override
    public void initFromJson(JsonValue json)
    {
        JsonObject obj = json.asObject();
        this.id = obj.getAsString("id");
        this.name = obj.getAsString("name");
        this.price = obj.getAsDouble("price");
        this.inStock = obj.getAsBoolean("inStock", false);
    }

    @Override
    public JsonValue toJsonValue()
    {
        JsonObject json = new JsonObject();
        json.put("id", id);
        json.put("name", name);
        json.put("price", price);
        json.put("inStock", inStock);
        return json;
    }
}

// Usage
Product product = new Product();
product.setId("SKU-001");
product.setName("Widget");
product.setPrice(29.99);
product.setInStock(true);

// Convert to JSON
JsonValue json = product.toJsonValue();
String jsonString = json.toString();

// JsonObject.put() accepts Jsonable directly
JsonObject order = new JsonObject();
order.put("product", product); // Automatically calls toJsonValue()

Benefits

Zero Configuration

JSON, XML, and Markdown all work out of the box—they're part of OorianCore. No configuration files, no dependency trees, no extra JARs.

Consistent API Style

All three APIs follow Oorian conventions: simple constructors, intuitive method names, and no boilerplate. If you know one, the others feel familiar.

Native Element Output

MarkdownParser produces real Oorian HTML elements—not raw HTML strings. You can style them, compose them with other components, and add event handlers just like any other element.

No External Dependencies

No Jackson, Gson, JAXB, CommonMark, or flexmark. JSON, XML, and Markdown are all built into OorianCore with zero transitive dependencies.

Full-Featured Markdown

Headings, paragraphs, bold, italic, strikethrough, links, images, code blocks, blockquotes, ordered and unordered lists, GFM tables, and horizontal rules.