Skip to content

Commit

Permalink
initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Cannizzaro committed Aug 19, 2017
1 parent 1524b61 commit e800832
Show file tree
Hide file tree
Showing 20 changed files with 582 additions and 74 deletions.
60 changes: 7 additions & 53 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,55 +1,9 @@
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries

# Keystore files
*.jks

# External native build folder generated in Android Studio 2.2 and later
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json
18 changes: 18 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

81 changes: 81 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# kson
Kotlin Json DSL

[![](https://jitpack.io/v/fcannizzaro/kson.svg)](https://jitpack.io/#fcannizzaro/kson)

## Dependecies

**Step 1**. Add the JitPack repository to your build file

```gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
```

**Step 2**. Add the dependency


```gradle
dependencies {
compile 'com.github.fcannizzaro:kson:1.0.0'
}
```

## Usage

```kotlin
val data = json {

entry("key", "value")

entry("array") {
val items = (1..4).map { "item $it" }.reversed()
items
}

entry("array-fast", array("fast 0", "fast 1"))

entry("another-key", "another-value")

}

println(data.toString(4))

```

### JSON Result

```json
{
"array-fast": ["fast 0", "fast 1"],
"array": ["item 4", "item 3", "item 2", "item 1"],
"another-key": "another-value",
"key": "value"
}
```

## Methods

### json(kson: KsonObject.() -> Unit)
Create a JSONObject.

### entry(key: String, value: Any?)
### entry(key: String, value: () -> Any?)
Add a new entry.

### array(vararg items: Any?)
### array(items : () -> Iterable<Any?>)
Create a JSONArray.

## Exceptions

### IllegalArgumentException
- Entry key cannot be **empty.**
- Entry value can only be **Int**, **Double**, **Float**, **String**, **JSONArray**, **JSONObject** or **Map.**

## Author
Francesco Saverio Cannizzaro (**fcannizzaro**)
27 changes: 27 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.1.4-2'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
17 changes: 17 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Sat Aug 19 13:30:10 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
Loading

0 comments on commit e800832

Please sign in to comment.