CycloneDX / CycloneDX/cyclonedx-core-java
Exception when serializing `extensibleTypes` to JSON
- Dominant language
- Java
- Stars
- 120
- Forks
- 90
- Avg merge
- 12h 43m
- Merged PRs (30d)
- 18
Description
In ORT, we're using `extensibleTypes` to record the ["origin" of a license](https://github.com/oss-review-toolkit/ort/blob/edbb46cb1dab1529d5ffb81cba18d365b98ef23e/reporter/src/main/kotlin/reporters/CycloneDxReporter.kt#L97) or the ["type" of a dependency](https://github.com/oss-review-toolkit/ort/blob/edbb46cb1dab1529d5ffb81cba18d365b98ef23e/reporter/src/main/kotlin/reporters/CycloneDxReporter.kt#L240). While serializing such a BOM to XML works fine, serializing the same BOM to JSON fails with:
```
com.fasterxml.jackson.databind.JsonMappingException:
class com.fasterxml.jackson.core.json.WriterBasedJsonGenerator cannot be cast to class com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator (com.fasterxml.jackson.core.json.WriterBasedJsonGenerator and com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator are in unnamed module of loader 'app')
(through reference chain: org.cyclonedx.model.Bom["components"]->java.util.ArrayList[0]->org.cyclonedx.model.Component["licenses"]->org.cyclonedx.model.License["extensibleTypes"])
```
From a quick glance, it seems to me that `extensibleTypes` serialization currently [is XML-specific](https://github.com/CycloneDX/cyclonedx-core-java/blob/63c5046409bcd11973ad25e2a9cbc324c90a1d31/src/main/java/org/cyclonedx/util/ExtensibleTypesSerializer.java). If that's the case, is there a chance to get JSON support for `extensibleTypes`?
Contributor guide
Assessment
This issue has not been assessed yet.