Adapters and converters for different serialization types. For example: from JSON to CSV, from TOML to YML, from CSV to SARIF, etc. You simply need to provide the mapping schema and kotlinx serialization library for it.
Initially, we wanted simply to create a small tool that will be able to convert custom formats that have a support in kotlinx.serialization to SARIF format.
Later we thought that it can be useful for other developers to have a common adapter for different serialization types.
If you would like to use this library as cli-app:
- Implement
@Serializable
data class that will be used for deserialization of an input - Implement a subclass of
AdapterProxy
. Preferable way is to useSarifAdapter
factory method, but if you need more granular control of functionality, you can extend classes directly. - Create a Service Provider Interface file
META-INF/services/org.cqfn.save.adapter.AdapterProxy
In case you plan to have an adapter as a library:
- Implement
@Serializable
data classes that will be used for deserialization and serialization of an input - ??? (set the INPUT and OUTPUT formats and proper libraries will be automatically added by the adapter)
- Provide these classes to the
KxSerializationAdapter
We have prepared some examples that can be found here.
Prerequisites: Java.
-
Put the fat-jar with your custom type into the same directory with
save-adapters.jar
-
Then write serialized representation of your data into app's stdin:
cat my-data.json | java -cp * org.cqfn.save.adapter.RunnerKt
-
Put the
fat-jar
with your custom type into the same directory withsave-adapters.jar
-
Run the following command to convert your file:
java -cp * org.cqfn.save.adapter.RunnerKt "/full/path/my-file-input" "/full/path/my-file-output.sarif"