Hello Tobias,
as of now, the AASX Deserializer only supports XML deserialization. However, you can overwrite its “read” function to use a JSON deserialized instead.
If you would like to contribute code that is able to handle both, we will very gladly accept your PR.
Best regards,
Frank
From: aas4j-dev <aas4j-dev-bounces@xxxxxxxxxxx>
On Behalf Of Tobias Kraft (exensio GmbH) via aas4j-dev
Sent: Montag, 8. April 2024 11:07
To: aas4j-dev@xxxxxxxxxxx
Cc: Tobias Kraft (exensio GmbH) <tobias.kraft@xxxxxxxxxx>
Subject: [aas4j-dev] Help when reading an AASX file that can contain JSON or XML data
I'm trying to read an AASX file, which can contain data in JSON or XML. When I receive the file, I don't know something about the content.
For my understanding, I can use the AASXDesirializer, which is working fine, as long as the data are stored in XML.
try (FileInputStream inputStream = new FileInputStream(file)) {
AASXDeserializer deserializer = new AASXDeserializer(inputStream)
aasEnvironment = deserializer.read()
}
When the data are stored in JSON I get an exception. When I look into the source code of the file
AASXDeserializer I can see that an XML-Serializer is used. Therefor it is clear that an exception occurs.
I can currently find no mechanism in the library to read an AASX file that contain JSON data. My expectation was that there is a functionality that processes an AASX file
and returns the environment, and it doesn't matter in which format the content is.
I would appreciate any help.
Thanks,
Tobias