Skip to content

JSON format ... doesn't differentiate between INT/FLOAT #66

@jvsteiner

Description

@jvsteiner

Since the mutation input is in JSON format which doesn't differentiate between INT/FLOAT (everything is a number), the server gets a float and stores the facet as such. This is, unfortunately, a limitation of the JSON format and the fact that facets don't have a fixed type.

I would recommend setting a property on a node (instead of facet) if the type is important to you or using the RDF mutation format.

Originally posted by @pawanrawal in #3 (comment)

This seems like a more general problem affecting node predicates as well. It seems at the moment, the only choices are:

  1. use mutation JSON, in which case I can't get my integers back out of the database, because they get converted to floats during unmarshalling
  2. Use NQuads and construct them myself.

In my use case, I have dynamic data, and I don't know what it looks like ahead of time, so I cannot unmarshal into a predefined struct.

I think a modified json.Unmarshaler which does not coerce ints might be helpful. Perhaps the standard lib code could be repurposed and modified relatively easily...

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/questionSomething requiring a response.status/acceptedWe were able to reproduce the issue and accept to work on it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions