Page MenuHomePhabricator

datatype should come before datavalue in snaks, not after
Open, Needs TriagePublic

Description

The TypedSnakSerializer of the DataModel Serialization library currently inserts the datatype after the snak has already been constructed and because PHP arrays are ordered this results in snaks like the following:

{
  "snaktype": "value",
  "property": "P958",
  "hash": "66529858390d6dc4356a30e5069c01a05e17f757",
  "datavalue": {
    "value": "Human Race",
    "type": "string"
  },
  "datatype": "string"
}

note how datatype comes after the datavalue. This is quite unfortunate because it disallows the most efficient deserialization (single pass and no allocations).

So I think it would be nice if TypedSnakSerializer put the datatype before the datavalue to allow for most efficient deserialization.