Giter Club home page Giter Club logo

Comments (3)

ryber avatar ryber commented on July 17, 2024 1

cc @petrdvorak Hi, this is a fork attempting to pick up where Unirest left off.

The problem here is twofold:

  1. Unirest does not come with a json ObjectMapper, you have to supply that, it only has the original org.json package
  2. TypeReference is a Jackson thing and isn't standard java. In gson they use TypeToken to do the same thing, Spring similarly has yet another of this famous hack.

Still there may be a way to pass one through to the Object Mapper. I'll take a look. If we can do it without taking sides then we will.

from unirest-java.

petrdvorak avatar petrdvorak commented on July 17, 2024

While I understand this might require a wider community consensus, looking into the docs, I wouldn't mind having Guava (that provides own TypeToken class) as a provided dependency for Unirest. We add it in all our projects anyway...

If having the extra dependency is an issue, just adding this topic in documentation would help - I remember I spent too much time when dealing with this issue for the first time. (Currently, we have it resolved in our projects.)

from unirest-java.

ryber avatar ryber commented on July 17, 2024

Hi @petrdvorak, sorry this has taken a while to get to. I ended up implementing my own Generic Type Reference. You can see how it's used here:

https://github.com/OpenUnirest/unirest-java/blob/master/src/test/java/BehaviorTests/AsGenericTypeTest.java

This can be used with either Jackson like this:
https://github.com/OpenUnirest/unirest-java/blob/master/src/test/java/io/github/openunirest/http/JacksonObjectMapper.java#L44-L50

Or With Gson
https://github.com/OpenUnirest/unirest-java/blob/master/src/test/java/io/github/openunirest/http/GsonObjectMapper.java#L15-L18

Or I suspect with any number of other mapping libraries.

2.4.00 should be in mvn central in about 20 minutes

from unirest-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.