Created
September 20, 2021 08:27
-
-
Save fcaylus/07b86ab379d7d0f5562dbba522655090 to your computer and use it in GitHub Desktop.
JSON to Smile encoding in Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val json = "{\"a\":1}" | |
val builder = SmileXContent.contentBuilder() | |
val parser = XContentFactory.xContent(XContentType.JSON).createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json) | |
builder.copyCurrentStructure(parser) | |
Files.write(Paths.get("test.sml"), BytesReference.toBytes(BytesReference.bytes(builder))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment