Verified Commit b4b0d3da authored by akwizgran's avatar akwizgran Committed by Torsten Grote

Allow null values in JsonDict.

parent 609c90f5
package org.briarproject.briar.headless.blogs
import org.briarproject.bramble.api.sync.MessageId
import org.briarproject.bramble.identity.output
import org.briarproject.briar.api.blog.BlogPostHeader
import org.briarproject.briar.api.blog.MessageType
import org.briarproject.briar.headless.json.JsonDict
internal fun BlogPostHeader.output(body: String): JsonDict {
val dict = JsonDict(
internal fun BlogPostHeader.output(body: String) = JsonDict(
"body" to body,
"author" to author.output(),
"authorStatus" to authorStatus.output(),
"type" to type.output(),
"id" to id.bytes,
"parentId" to parentId?.bytes,
"read" to isRead,
"rssFeed" to isRssFeed,
"timestamp" to timestamp,
"timestampReceived" to timeReceived
)
if (parentId != null) dict["parentId"] = (parentId as MessageId).bytes
return dict
}
internal fun MessageType.output() = name.toLowerCase()
package org.briarproject.briar.headless.json
class JsonDict(vararg pairs: Pair<String, Any>) : HashMap<String, Any>(pairs.size) {
class JsonDict(vararg pairs: Pair<String, Any?>) : HashMap<String, Any?>(pairs.size) {
init {
putAll(pairs)
}
fun putAll(vararg pairs: Pair<String, Any>) {
fun putAll(vararg pairs: Pair<String, Any?>) {
for (p in pairs) put(p.first, p.second)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment