Giter Site home page Giter Site logo

halbuilder-json's People

Contributors

epipho avatar slovdahl avatar talios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

halbuilder-json's Issues

Please push the latest code to maven

Hi Mark, do you mind pushing the latest code to maven? I'm having an issue with NPEs deserializing maps that have null values. I think this commit will probably resolve the issue since the root of the problem is in ImmutableMap.

Thanks!
Damon

Inconsistent behavior with _links vs _embedded _links

Hi,

See below, I would expect the _embedded.items.applicants not to be an array.

{
  "_links": {
    "self": {
      "href": "https://localhost:8443/applications"
    }
  },
  "_embedded": {
    "items": [
      {
        "_links": {
          "self": {
            "href": "https://localhost:8443/applications/11111111"
          },
          "applicants": [
            {
              "href": "https://localhost:8443/applications/11111111/applicants"
            }
          ]
        }
      }
    ]
  }
}

Support for Joda Date Time

Is there plan to support Joda Date time ? Currently, I am converting my date into W3C formatted string, but it will be great if we can add support for Joda Date Time. Let me know , and I can submit a PR for the same.

Allow null values in property objects

Hi,

Currently, null values in objects are not allowed, as JsonRepresentationReader uses Guava's ImmutableMap internally, which does not permit null keys or values. While it may be dubious practice to have a null value (as returning a null value from a Java Map may mean either the key does not exist or it does exist and is null), however, this is still valid JSON, which means it probably should be handled.

The simplest solution looks to be to remove the ImmutableMap.copyOf wrapper.

resource.withProperty(fieldName, field.isNull()
? null
: ( !field.isContainerNode() ? field.asText() : ImmutableMap.copyOf(mapper.readValue(field.toString(), Map.class))));

example failing HAL extract:

  {
    .... 
    "page": {
       "offset": null,
       "limit": null
     },
   ...
 }

Thanks.

Support for empty arrays in the embedded representations

As far as I've checked it's not possible to add a sub representation which will yield an empty array in the "_embedded" field.

I've modified the repositories to enable this.

Trying to serialise this representation:

    String href = "customer/123456";
    ReadableRepresentation party = newBaseResource(href)
                                       .withLink("ns:users", BASE_URL + href + "?users")
                                       .withRepresentation("ns:users",  representationFactory
                                           .newRepresentation("1")
                                           .setEmptySubRepresentation(true));

will yield the following JSON:

{
  "_links" : {
    "curies" : [ {
      "href" : "https://example.com/apidocs/ns/{rel}",
      "name" : "ns",
      "templated" : true
    }, {
      "href" : "https://example.com/apidocs/role/{rel}",
      "name" : "role",
      "templated" : true
    } ],
    "self" : {
      "href" : "https://example.com/api/customer/123456"
    },
    "ns:parent" : {
      "href" : "https://example.com/api/customer/1234",
      "name" : "bob",
      "title" : "The Parent",
      "hreflang" : "en"
    },
    "ns:users" : {
      "href" : "https://example.com/api/customer/123456?users"
    }
  },
  "_embedded" : {
    "ns:users" : [ ]
  }
}

JsonRepresentationReader does not return links

If you call representationReader.read(reader); with an HAL compliant JSON structure you can't access the link objects via representation.getLinkByRel("books").

Internaly the read function calls readLinks function in JsonRepresentationReader. At the second line the function tries to get an Iterator with all fields of the links. (rootNode.get(LINKS).fields()). This nerver works because the method fields() method of the ArrayNode class isn't overridden (FasterXML jackson-databind Issue).

Unable to receive array properties

Hi,

If folks is an array of strings, this:
rep.withProperty("folks", user.getFolks());
produces this:
"folks":["Bob","Carol","Ted"],
So arrays are output successfully.
Unfortunately when reading it back in this line in readProperties:
resource.withProperty(fieldName, field.isNull() ? null : field.asText());
produces an empty string.

I can't see anything in the HAL specification that says properties can't be arrays (in fact it claims everything except the links can be any valid JSON).
Is this an intentional behaviour or a bug?

Thanks

Object properties are not parsed correctly

I have a JSON with the following property:

  ...
   "id" : 63,
   "primary_number" : {
      "ac" : "221",
      "cc" : "49",
      "sn" : "16804109"
   },
   "password" : "secret",
  ....

The JsonRepresentationReader class uses readProperties() to read these property but it only tests if the value is a JSON Arrays, in which case it creates an List, and else stores it as String.

In my example the correct behaviour for the "primary_number" property would be to check for a JSON Object and store that as HashMap.

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.