jkob

Kotlin DSL for type-safe JSON building

License

License

Categories

Categories

Net
GroupId

GroupId

net.soundvibe
ArtifactId

ArtifactId

jkob
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

jkob
Kotlin DSL for type-safe JSON building
Project URL

Project URL

https://github.com/soundvibe/jkob
Source Code Management

Source Code Management

https://github.com/soundvibe/jkob.git

Download jkob

How to add to project

<!-- https://jarcasting.com/artifacts/net.soundvibe/jkob/ -->
<dependency>
    <groupId>net.soundvibe</groupId>
    <artifactId>jkob</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.soundvibe/jkob/
implementation 'net.soundvibe:jkob:1.0.0'
// https://jarcasting.com/artifacts/net.soundvibe/jkob/
implementation ("net.soundvibe:jkob:1.0.0")
'net.soundvibe:jkob:jar:1.0.0'
<dependency org="net.soundvibe" name="jkob" rev="1.0.0">
  <artifact name="jkob" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.soundvibe', module='jkob', version='1.0.0')
)
libraryDependencies += "net.soundvibe" % "jkob" % "1.0.0"
[net.soundvibe/jkob "1.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jre8 jar 1.1.4-2

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.jetbrains.kotlin : kotlin-test-junit jar 1.1.4-2

Project Modules

There are no modules declared in this project.

jkob

Build Status Maven Central

Kotlin DSL for type-safe JSON building

An example of building JSON:
val json = json {
    "id" to "value" //key->value pair
    "name" to "foo"
    "items" ["value1", "value2", "value3"] //array
    for (i in 1..2) "item$i" to i //you can even use regular loops when building JSON
    "numbers" [1, 2, 3]
    "child" { //child object
        "age" to 19
        "isValid" to false
        "isNull" to null
    }
}

This JSON object representation can be converted to JSON string:

val jsonString = json.toString()

Output:

{"id": "value", "name": "foo", "items": ["value1", "value2", "value3"], "item1": 1, "item2": 2, "numbers": [1, 2, 3], "child": {"age": 19, "isValid": false, "isNull": null}}
An example to retrieve elements from JSON:
val numbers = json["numbers"]?.toList<Int>()
println(numbers) //prints [1, 2, 3]

Binaries

Binaries and dependency information for Maven, Ivy, Gradle and others can be found at http://search.maven.org.

Example for Gradle:

compile 'net.soundvibe:jkob:1.0.0'

and for Maven:

<dependency>
    <groupId>net.soundvibe</groupId>
    <artifactId>jkob</artifactId>
    <version>1.0.0</version>
</dependency>

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

LICENSE

Copyright 2017 Linas Naginionis

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy to the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Versions

Version
1.0.0