An open API service indexing awesome lists of open source software.

https://github.com/jwerle/kotlin-parson-bindings

Kotlin/Native bindings for parson, a JSON C library
https://github.com/jwerle/kotlin-parson-bindings

bindings json konanc kotlin native parser parson stringify

Last synced: 2 months ago
JSON representation

Kotlin/Native bindings for parson, a JSON C library

Awesome Lists containing this project

README

        

kotlin-parson-bindings
======================

Kotlin/Native bindings for [parson](https://github.com/kgabis/parson/), a JSON C library

## Installation

```sh
$ npm install kotlin-parson-bindings
```

## Linking

Use directly with [konanc-config](https://github.com/konanc-config/konanc-config)

```sh
$ konanc main.kt -p program -o main.kexe $(konanc-config --repos --libs kotlin-parson-bindings)
```

or add to a `lib.kc` file

```ini
require[] = "kotlin-parson-bindings"
```

## Example

```kotlin
import parson.json_object_get_string
import parson.json_parse_string
import parson.json_object

import kotlinx.cinterop.toKString

fun main(argv: Array) {
val root = json_parse_string("""{"key": "value"}""")
val value = json_object_get_string(json_object(root), "key")
println(value) // value
}
```

## API

Generated from [parson.h](deps/parson/parson.h) with
[cinterop](https://github.com/JetBrains/kotlin-native/blob/master/INTEROP.md).

```kotlin
typealias json_value_typeVar = IntVarOf
typealias json_value_type = Int

val JSONError: json_value_type get() = -1
val JSONNull: json_value_type get() = 1
val JSONString: json_value_type get() = 2
val JSONNumber: json_value_type get() = 3
val JSONObject: json_value_type get() = 4
val JSONArray: json_value_type get() = 5
val JSONBoolean: json_value_type get() = 6

typealias json_result_tVar = IntVarOf
typealias json_result_t = Int

val JSONSuccess: json_result_t get() = 0
val JSONFailure: json_result_t get() = -1

typealias JSON_Object = json_object_t

typealias JSON_Array = json_array_t

typealias JSON_Value = json_value_t

typealias JSON_Value_TypeVar = IntVarOf
typealias JSON_Value_Type = Int

typealias JSON_StatusVar = IntVarOf
typealias JSON_Status = Int

typealias JSON_Malloc_FunctionVar = CPointerVarOf
typealias JSON_Malloc_Function = CPointer COpaquePointer?>>

typealias JSON_Free_FunctionVar = CPointerVarOf
typealias JSON_Free_Function = CPointer Unit>>

fun json_set_allocation_functions(malloc_fun: JSON_Malloc_Function?, free_fun: JSON_Free_Function?): Unit
fun json_parse_file(filename: String?): CPointer?
fun json_parse_file_with_comments(filename: String?): CPointer?
fun json_parse_string(string: String?): CPointer?
fun json_parse_string_with_comments(string: String?): CPointer?
fun json_serialization_size(value: CValuesRef?): size_t
fun json_serialize_to_buffer(value: CValuesRef?, buf: CValuesRef?, buf_size_in_bytes: size_t): JSON_Status
fun json_serialize_to_file(value: CValuesRef?, filename: String?): JSON_Status
fun json_serialize_to_string(value: CValuesRef?): CPointer?
fun json_serialization_size_pretty(value: CValuesRef?): size_t
fun json_serialize_to_buffer_pretty(value: CValuesRef?, buf: CValuesRef?, buf_size_in_bytes: size_t): JSON_Status
fun json_serialize_to_file_pretty(value: CValuesRef?, filename: String?): JSON_Status
fun json_serialize_to_string_pretty(value: CValuesRef?): CPointer?
fun json_free_serialized_string(string: CValuesRef?): Unit
fun json_value_equals(a: CValuesRef?, b: CValuesRef?): Int
fun json_validate(schema: CValuesRef?, value: CValuesRef?): JSON_Status
fun json_object_get_value(`object`: CValuesRef?, name: String?): CPointer?
fun json_object_get_string(`object`: CValuesRef?, name: String?): CPointer?
fun json_object_get_object(`object`: CValuesRef?, name: String?): CPointer?
fun json_object_get_array(`object`: CValuesRef?, name: String?): CPointer?
fun json_object_get_number(`object`: CValuesRef?, name: String?): Double
fun json_object_get_boolean(`object`: CValuesRef?, name: String?): Int
fun json_object_dotget_value(`object`: CValuesRef?, name: String?): CPointer?
fun json_object_dotget_string(`object`: CValuesRef?, name: String?): CPointer?
fun json_object_dotget_object(`object`: CValuesRef?, name: String?): CPointer?
fun json_object_dotget_array(`object`: CValuesRef?, name: String?): CPointer?
fun json_object_dotget_number(`object`: CValuesRef?, name: String?): Double
fun json_object_dotget_boolean(`object`: CValuesRef?, name: String?): Int
fun json_object_get_count(`object`: CValuesRef?): size_t
fun json_object_get_name(`object`: CValuesRef?, index: size_t): CPointer?
fun json_object_set_value(`object`: CValuesRef?, name: String?, value: CValuesRef?): JSON_Status
fun json_object_set_string(`object`: CValuesRef?, name: String?, string: String?): JSON_Status
fun json_object_set_number(`object`: CValuesRef?, name: String?, number: Double): JSON_Status
fun json_object_set_boolean(`object`: CValuesRef?, name: String?, boolean: Int): JSON_Status
fun json_object_set_null(`object`: CValuesRef?, name: String?): JSON_Status
fun json_object_dotset_value(`object`: CValuesRef?, name: String?, value: CValuesRef?): JSON_Status
fun json_object_dotset_string(`object`: CValuesRef?, name: String?, string: String?): JSON_Status
fun json_object_dotset_number(`object`: CValuesRef?, name: String?, number: Double): JSON_Status
fun json_object_dotset_boolean(`object`: CValuesRef?, name: String?, boolean: Int): JSON_Status
fun json_object_dotset_null(`object`: CValuesRef?, name: String?): JSON_Status
fun json_object_remove(`object`: CValuesRef?, name: String?): JSON_Status
fun json_object_dotremove(`object`: CValuesRef?, key: String?): JSON_Status
fun json_object_clear(`object`: CValuesRef?): JSON_Status
fun json_array_get_value(array: CValuesRef?, index: size_t): CPointer?
fun json_array_get_string(array: CValuesRef?, index: size_t): CPointer?
fun json_array_get_object(array: CValuesRef?, index: size_t): CPointer?
fun json_array_get_array(array: CValuesRef?, index: size_t): CPointer?
fun json_array_get_number(array: CValuesRef?, index: size_t): Double
fun json_array_get_boolean(array: CValuesRef?, index: size_t): Int
fun json_array_get_count(array: CValuesRef?): size_t
fun json_array_remove(array: CValuesRef?, i: size_t): JSON_Status
fun json_array_replace_value(array: CValuesRef?, i: size_t, value: CValuesRef?): JSON_Status
fun json_array_replace_string(array: CValuesRef?, i: size_t, string: String?): JSON_Status
fun json_array_replace_number(array: CValuesRef?, i: size_t, number: Double): JSON_Status
fun json_array_replace_boolean(array: CValuesRef?, i: size_t, boolean: Int): JSON_Status
fun json_array_replace_null(array: CValuesRef?, i: size_t): JSON_Status
fun json_array_clear(array: CValuesRef?): JSON_Status
fun json_array_append_value(array: CValuesRef?, value: CValuesRef?): JSON_Status
fun json_array_append_string(array: CValuesRef?, string: String?): JSON_Status
fun json_array_append_number(array: CValuesRef?, number: Double): JSON_Status
fun json_array_append_boolean(array: CValuesRef?, boolean: Int): JSON_Status
fun json_array_append_null(array: CValuesRef?): JSON_Status
fun json_value_init_object(): CPointer?
fun json_value_init_string(string: String?): CPointer?
fun json_value_init_number(number: Double): CPointer?
fun json_value_init_boolean(boolean: Int): CPointer?
fun json_value_init_null(): CPointer?
fun json_value_deep_copy(value: CValuesRef?): CPointer?
fun json_value_free(value: CValuesRef?): Unit
fun json_value_get_type(value: CValuesRef?): JSON_Value_Type
fun json_value_get_object(value: CValuesRef?): CPointer?
fun json_value_get_array(value: CValuesRef?): CPointer?
fun json_value_get_string(value: CValuesRef?): CPointer?
fun json_value_get_number(value: CValuesRef?): Double
fun json_value_get_boolean(value: CValuesRef?): Int
fun json_type(value: CValuesRef?): JSON_Value_Type
fun json_object(value: CValuesRef?): CPointer?
fun json_array(value: CValuesRef?): CPointer?
fun json_string(value: CValuesRef?): CPointer?
fun json_number(value: CValuesRef?): Double
fun json_boolean(value: CValuesRef?): Int

```

## License

MIT