Skip to content

Using arbitrary ID as key in an array #24

@edas

Description

@edas

Many web applications use a notation like mymodel[141253][name] where 141253 is the identifier of the described mymodel object.

In the current spec, this will create a JSON array with the key mymodel. In this array, 141252 explicit nullitems will be created, which will be suboptimal both for the size of the JSON message and for the processing time of the recipient.

AFAIK, JSON won't allow to use an array structure with arbitrary keys without explictly creating all keys in the sequence.

One solution would be to always convert mymodel[141253][name] to hash and never to array, generating

{
  "mymodel": {
    "141253": {
      "name": ""
    }
  }
}

This seems less smart than the current spec, but won't bug on this common use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions