question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add java.lang.reflect.Type to deserialize API

See original GitHub issue

Describe the proposal

As discussed https://github.com/dapr/java-sdk/issues/293 , TypeRef<T> was added to support deserialization of generic types. However, instances of TypeRef<T> can only be statically (during compilation) created. There are occasions when generic types need to be dynamically created. I suggest adding the following method to deserialize API to support such cases. <T> T deserialize(byte[] data, java.lang.reflect.Type type) throws IOException

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
xiazuojiecommented, Sep 9, 2020

The default serializer uses java.lang.reflect.Type. See type.getType() in the implementation below. Is this what you need?

  public <T> T deserialize(byte[] content, TypeRef<T> type) throws IOException {
    return deserialize(content, OBJECT_MAPPER.constructType(type.getType()));
  }

Not what I want. I need the following api. <T> T deserialize(byte[] data, java.lang.reflect.Type type) throws IOException

Note that one cannot create an instance of TypeRef<T> from java.lang.reflect.Type dynamically.

0reactions
mukundansundarcommented, Jan 23, 2021

closed by #449

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simple code to get java.lang.reflect.Type - Stack Overflow
Simple code to get java.lang.reflect.Type ... GSON's toJson function takes a type argument which checks the Type when reflecting the object. This is...
Read more >
Example usage for java.lang.reflect Type equals - Java2s.com
Indicates whether some other object is "equal to" this one. Usage. From source file:io.swagger.client.ApiClient.java /** * Deserialize response body to Java ...
Read more >
ApiClient (orbipay-paymentsapi-client 1.11.0 API)
Response response, java.lang.reflect.Type returnType). Deserialize response body to Java object, according to the return type and the Content-Type response ...
Read more >
Uses of Class com.google.gson.JsonElement - Javadoc.io
JsonElement, JsonSerializer. serialize(T src, java.lang.reflect.Type typeOfSrc, JsonSerializationContext context). Gson invokes this call-back method during ...
Read more >
EventGridSubscriber Class - Microsoft Learn
The type that can be used to de-serialize eventgrid events. ... Set<java.util.Map.Entry<java.lang.String,java.lang.reflect.Type>>.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found