HPInc / jipp

A Java-compatible implementation of IPP
MIT License
153 stars 42 forks source link

Serializing and Deserializing IppPacket to JSON using Jackson mapper #151

Closed sbhavana closed 6 months ago

sbhavana commented 1 year ago

Hi,

I am building a test client which takes in a JSON and creates an IppPacket from it. For this, I am using Jackson Object mapper to de-serialize JSON to IppPacket. But it is running into following issue:

com.fasterxml.jackson.databind.JsonMappingException: Cannot find a deserializer for non-concrete Collection type [collection type; class com.hp.jipp.encoding.AttributeGroup, contains [collection type; class com.hp.jipp.encoding.Attribute, contains [simple type, class java.lang.Object]]]

This issue occurs because com.hp.jipp.encoding.AttributeGroup and com.hp.jipp.encoding.Attribute are interfaces. This issue can be resolved by telling Jackson Object mapper to use Impl classes: com\hp\jipp\encoding\AttributeGroupImpl and C:\Users\bhav\GitRepos\jipp\jipp-core\src\main\java\com\hp\jipp\encoding\AttributeImpl. But these are internal classes so I can not use these outside of JIPP.

How can this be solved ? Kindly suggest.

Best, Bhavana

HPNavjot commented 1 year ago

@sbhavana the fix is available in the latest beta release.