Skip to end of metadata
Go to start of metadata

halarious is a simple framework for serializing and deserializing Java-Classes to JSON following the HAL-specification

  • HAL is a simple format that gives a consistent and easy way to hyperlink between resources in your API.

  • halarious is based on GSON, a lightweight library by Google.
  • References and embedded fields can simply be marked with annotations. No further configuration nedded.

 

Java
JSON
Converter
  • No labels

10 Comments

  1. Anonymous

    JSONARRAY CONNOT BE CAST TO JSONOBJECT;

  2. Anonymous

     java.lang.ClassCastException: com.google.gson.JsonArray cannot be cast to com.google.gson.JsonObject

    at com.google.gson.JsonObject.getAsJsonObject(JsonObject.java:182)
    at com.miaole.miaoleapp.halariourjson.HalDeserializer.deserialize(HalDeserializer.java:64)
    at com.miaole.miaoleapp.halariourjson.HalDeserializer.deserialize(HalDeserializer.java:54)
    at com.miaole.miaoleapp.halariourjson.HalDeserializer.deserialize(HalDeserializer.java:36)

  3. Anonymous

    forgot to add head "application/hal+json"

  4. Anonymous

    In the "_embedded" section "self" can have multiple links. If there's just a single link it will be parsed into an object causing problems during deserialization.
    >> http://stackoverflow.com/questions/35037423/return-an-array-with-a-single-element-using-gson-and-hal-hypertext-application

  5. Anonymous

    Have an issue with list<String> value (

    ex:

    @HalLink(name = "u:a")
    private List<String> a = new ArrayList<String>(); )

    while deserializing it returns Collection is null; no values can be added.

    in the response it returns {"_link":{ "u:a": [], .. other links..}..some other stuff..}

    Any suggestions?

  6. Anonymous

    how to solve ch.hilarious.core.Hal Deserializing Exception: Collection is null; no values can be added?

    service returns a proper json array. for the embeded field.. 

  7. Anonymous

    I'm having the same problem (ch.hilarious.core.HalDeserializingException). Anyone was able to solve it?

  8. Anonymous

    I solved "ch.hilarious.core.Hal Deserializing Exception: Collection is null; no values can be added" by initializing the ArrayList declared. 

    @HalEmbedded
    private ArrayList<Product> products = new ArrayList<>();
  9. Anonymous

    If I try to use @SerializedName annotation with @HalEmbedded it doesn't work. Any ideas why?

  10. Anonymous

    The example above is wrong.  The _embedded "manufacturer" name and homepage href are mixed up.

Write a comment…