Skip to content

Is it possible to check if a type has been registered with Jsonb #414

@vamega

Description

@vamega

I was looking to create a helidon-http-media library such that classes could be used directly with the helidon WebClient. I think I need to have a way to identify if a class is deserializable by this library (i.e. if a JsonAdapter has been registered for it). I've not been able to find a way to do that lookup without attempting to perform the serialization and catching an exception.

Right now it appears I must attempt to serialize/deserialize things and catch the exception to identify if serialization/deserialization is possible.

  try {
    JsonAdapter<MyClass> adapter = jsonb.adapter(MyClass.class);
    // adapter exists, can use jsonb
  } catch (IllegalArgumentException e) {
    // no adapter found, use alternative approach
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions