Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

JsonArray cannot be created #414

Closed
vertexpipeline opened this issue Aug 16, 2017 · 5 comments
Closed

JsonArray cannot be created #414

vertexpipeline opened this issue Aug 16, 2017 · 5 comments

Comments

@vertexpipeline
Copy link

vertexpipeline commented Aug 16, 2017

I cannot create JsonArray, while serialize JsonModel.

val foldersProperty = SimpleObjectProperty<ArrayList<FolderInfo>>()
    var folders by foldersProperty

    override fun toJSON(json: JsonBuilder) {
        with(json) {
            
        }
    }

How can i create array of files?

@edvin
Copy link
Owner

edvin commented Aug 16, 2017

Provided that FolderInfo is a JsonModel, just do:

add("folders", folders.toJSON())

Complete example:

class FolderInfo : JsonModel {
    val nameProperty = SimpleStringProperty()
    val name by nameProperty

    override fun toJSON(json: JsonBuilder) {
        with (json) {
            add("name", name)
        }
    }
}

class SomeObject : JsonModel {
    val foldersProperty = SimpleListProperty<FolderInfo>()
    var folders by foldersProperty

    override fun toJSON(json: JsonBuilder) {
        with(json) {
            add("folders", folders.toJSON())
        }
    }

edvin pushed a commit that referenced this issue Aug 16, 2017
@edvin
Copy link
Owner

edvin commented Aug 16, 2017

I just added a function so you can avoid the toJSON() call in the next release:

add("folders", folders)

@vertexpipeline
Copy link
Author

Thanks. I waited it.

@edvin
Copy link
Owner

edvin commented Aug 16, 2017

You can just add .toJSON() for now and upgrade after the next release, or use a snapshot release. The first one with this addition will be available at 16:00 GMT.

@vertexpipeline
Copy link
Author

I just used a older version, thanks for solving

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants