-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ELM JSON reader and writer (Kotlin feature branch) (#1489)
* JSON serializers for QName and BigDecimal. Initial cleanup. * Fix Sonar warnings --------- Co-authored-by: Jonathan Percival <[email protected]>
- Loading branch information
Showing
20 changed files
with
141 additions
and
98 deletions.
There are no files selected for viewing
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
15 changes: 15 additions & 0 deletions
15
...xmlutil/src/main/java/org/cqframework/cql/elm/serializing/xmlutil/ElmJsonLibraryCommon.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.cqframework.cql.elm.serializing.xmlutil | ||
|
||
import kotlinx.serialization.json.Json | ||
import kotlinx.serialization.modules.plus | ||
import kotlinx.serialization.modules.serializersModuleOf | ||
import org.hl7.elm_modelinfo.r1.serializing.BigDecimalJsonSerializer | ||
|
||
val json = Json { | ||
serializersModule = | ||
serializersModuleOf(BigDecimalJsonSerializer) + | ||
org.hl7.elm.r1.serializersModule + | ||
org.hl7.cql_annotations.r1.serializersModule | ||
explicitNulls = false | ||
ignoreUnknownKeys = true | ||
} |
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
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
20 changes: 20 additions & 0 deletions
20
...-xmlutil/src/main/java/org/cqframework/cql/elm/serializing/xmlutil/ElmXmlLibraryCommon.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.cqframework.cql.elm.serializing.xmlutil | ||
|
||
import kotlinx.serialization.modules.plus | ||
import kotlinx.serialization.modules.serializersModuleOf | ||
import nl.adaptivity.xmlutil.QName | ||
import nl.adaptivity.xmlutil.serialization.XML | ||
import org.hl7.elm_modelinfo.r1.serializing.BigDecimalXmlSerializer | ||
|
||
val xml = | ||
XML( | ||
serializersModuleOf(BigDecimalXmlSerializer) + | ||
org.hl7.elm.r1.serializersModule + | ||
org.hl7.cql_annotations.r1.serializersModule | ||
) { | ||
xmlDeclMode = nl.adaptivity.xmlutil.XmlDeclMode.Charset | ||
defaultPolicy { | ||
typeDiscriminatorName = | ||
QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi") | ||
} | ||
} |
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
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
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
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
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
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
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
27 changes: 27 additions & 0 deletions
27
...java/model/src/jvmMain/kotlin/org/hl7/elm_modelinfo/r1/serializing/QNameJsonSerializer.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.hl7.elm_modelinfo.r1.serializing | ||
|
||
import kotlinx.serialization.descriptors.* | ||
import kotlinx.serialization.encoding.* | ||
import nl.adaptivity.xmlutil.* | ||
|
||
|
||
@OptIn(ExperimentalXmlUtilApi::class) | ||
object QNameJsonSerializer : XmlSerializer<QName> by QNameSerializer { | ||
@OptIn(XmlUtilInternal::class) | ||
override val descriptor: SerialDescriptor = | ||
PrimitiveSerialDescriptor("javax.xml.namespace.QName", PrimitiveKind.STRING).xml( | ||
PrimitiveSerialDescriptor("javax.xml.namespace.QName", PrimitiveKind.STRING), | ||
QName(XMLConstants.XSD_NS_URI, "QName", XMLConstants.XSD_PREFIX) | ||
) | ||
|
||
override fun serialize(encoder: Encoder, value: QName) { | ||
encoder.encodeString( | ||
value.toString() | ||
) | ||
} | ||
|
||
override fun deserialize(decoder: Decoder): QName { | ||
return QName.valueOf(decoder.decodeString()) | ||
} | ||
} | ||
|
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
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
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
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
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
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
Oops, something went wrong.