Skip to content

alexwestphal/kompat-json-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kompat-json-lib

A Kotlin compatibility layer for working with the net.sf.json-lib JSON Library.

Download Kotlin GitHub license

Building JSON

import nz.ahw.kompat.jsonlib.*

val values = jsonArrayOf(1,2,3) // [1,2,3]

val json = jsonObjectOf("values" to values) // {"values":[1,2,3]}

Add To an existing JSON Object

json["message"] = "An important note" 

Add to an existing JSON Array

values += 4

Checking for Keys

if("message" in json) { ... }

Maven

Configure to use the kompat repository

<repository>
    <id>bintray-ahwnz-kompat</id>
    <name>bintray-kompat</name>
    <url>https://dl.bintray.com/ahwnz/kompat</url>
</repository>

Add the dependency

<dependency>
    <groupId>nz.ahw.kompat</groupId>
    <artifactId>kompat-json-lib</artifactId>
    <version>{version}</version>
</dependency>