All Projects → helpermethod → molten-json

helpermethod / molten-json

Licence: Apache-2.0 license
A fluent Java 8 DSL for building JSON documents.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to molten-json

Fluentscheduler
Automated job scheduler with fluent interface for the .NET platform.
Stars: ✭ 2,310 (+12057.89%)
Mutual labels:  fluent
website
Fully responsive website built with NextJS, React and Fluent UI, with the aim of providing services and access to all groups of didactic courses and general purposes to students of the University of Milan.
Stars: ✭ 29 (+52.63%)
Mutual labels:  fluent
Fluent-Random-Picker
Fluent Random Picker is a nice, performant, fluent way to pick random values. Probabilities can be specified, values can be weighted.
Stars: ✭ 26 (+36.84%)
Mutual labels:  fluent
Webpack Chain
A chaining API to generate and simplify the modification of Webpack configurations.
Stars: ✭ 2,821 (+14747.37%)
Mutual labels:  fluent
angular-odata-es5
OData Service for Angular.io (es5 version)
Stars: ✭ 45 (+136.84%)
Mutual labels:  fluent
MediaFlyout
Windows 10+ Media Control Taskbar Flyout
Stars: ✭ 87 (+357.89%)
Mutual labels:  fluent
Graphicscontrols
Experimental GraphicsControls - Build drawn controls (Cupertino, Fluent and Material)
Stars: ✭ 149 (+684.21%)
Mutual labels:  fluent
fluent-forward-go
A high-performance Go client for Fluentd and Fluent Bit
Stars: ✭ 26 (+36.84%)
Mutual labels:  fluent
paginator
Offset pagination for Vapor 🗂
Stars: ✭ 67 (+252.63%)
Mutual labels:  fluent
fluent-postgres-driver
🐘 PostgreSQL driver for Fluent.
Stars: ✭ 120 (+531.58%)
Mutual labels:  fluent
Fluentdocker
Commands, Services and Fluent API for docker, docker-compose & docker-machine, for win/mac/linux and native docker in c#
Stars: ✭ 245 (+1189.47%)
Mutual labels:  fluent
Fluent-Design-For-Web
Windows 10 Inspired UI For Web
Stars: ✭ 28 (+47.37%)
Mutual labels:  fluent
FluentExcel
Use Fluent API to configure POCO excel behaviors, and then provides IEnumerable<T> has save to and load from excel functionalities.
Stars: ✭ 73 (+284.21%)
Mutual labels:  fluent
Vuent
🎨 Vue.js components implementing Microsoft Fluent Design
Stars: ✭ 207 (+989.47%)
Mutual labels:  fluent
Microsoft.Maui.Graphics.Controls
Experimental Microsoft.Maui.Graphics.Controls - Build drawn controls (Cupertino, Fluent and Material)
Stars: ✭ 549 (+2789.47%)
Mutual labels:  fluent
Consoletableext
A fluent library to print out a nicely formatted table in a console application C#
Stars: ✭ 158 (+731.58%)
Mutual labels:  fluent
fluent-mysql-driver
🖋🐬 Swift ORM (queries, models, relations, etc) built on MySQL.
Stars: ✭ 69 (+263.16%)
Mutual labels:  fluent
fluentcheck
Fluent assertions for Python
Stars: ✭ 79 (+315.79%)
Mutual labels:  fluent
cargo-i18n
A Rust Cargo sub-command and libraries to extract and build localization resources to embed in your application/library
Stars: ✭ 88 (+363.16%)
Mutual labels:  fluent
slf4j-fluent
A fluent api for SLF4J
Stars: ✭ 19 (+0%)
Mutual labels:  fluent

Molten JSON

Download Hex.pm

molten-json is a fluent Java 8 DSL for building JSON documents.

Example

{
    "name": "molten-json",
    "version": "0.1.0",
    "description": "A fluent Java 8 DSL for working with JSON.",
    "repository": {
        "type": "git",
        "url": "https://github.com/helpermethod/molten-json"
    },
    "keywords": ["json", "java-8", "fluent", "dsl"],
    "author": "helpermethod",
    "license": "Apache 2",
    "bugs": {
        "url": "https://github.com/helpermethod/molten-json/issues"
    }
}
String project = new Json()
    .object(o -> o
        .string("name", "molten-json")
        .string("version", "0.1.0")
        .string("description", "A fluent Java 8 DSL for working with JSON.")
        .object("repository", r -> r
            .string("type", "git")
            .string("url", "https://github.com/helpermethod/molten-json"))
        .array("keywords", k -> k.strings("json", "java-8", "fluent", "dsl"))
        .string("author", "helpermethod")
        .string("license", "Apache 2")
        .object("bugs", b -> b
            .string("url", "https://github.com/helpermethod/molten-json/issues")))
    .toPrettyString();

Getting Started

Maven

<repositories>
    <repository>
        <id>bintray</id>
        <url>http://dl.bintray.com/helpermethod/maven</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.helpermethod</groupId>
        <artifactId>molten-json</artifactId>
        <version>0.1.0</version>
    </dependency>
</dependencies>

Gradle

repositories {
    maven {
        url 'http://dl.bintray.com/helpermethod/maven'
    }
}

dependencies {
    compile 'com.helpermethod:molten-json:0.1.0'
}

Usage

Creating an empty JSONObject

JSONObject project = new Json().object().toJson();

Creating a JSONObject with one string property

JSONObject project = new Json().object(o -> o.string("name", "molten-json"));

Creating an empty JSONArray

JSONArray keywords = new Json().array().toJson();

Creating a JSONArray with one string element

JSONArray keywords = new Json().array(a -> a.strings("json"))

Creating a JSONArray with multiple string elements

JSONArray keywords = new Json().array(a -> a.strings("json", "java-8", "fluent", "dsl"))

Creating a JSON string

String project = new Json().object(o -> o.string("name", "molten-json")).toString();

Creating a pretty-printed JSON string

String project = new Json().object(o -> o.string("name", "molten-json")).toPrettyString();

Creating a nested JSONObject

JSONObject project = new Json()
    .object(o -> o
        .string("name", "molten-json")
        .string("version", "0.1.0"))
        .object("repository", r -> r
            .string("type", "git")
            .string("url", "https://github.com/helpermethod/molten-json")))
    .toJson();    

Ignoring properties with null values

String version = null;

JSONObject project = new Json(NullHandlingStrategy.IGNORE_NULL)
    .object(o -> o
        .string("name", "molten-json")
        .string("version", version))
    .toJson();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].