REP-003 - JSON serialization

From RestAuth
Jump to: navigation, search

This document specifies REP-003 - JSON serialization, enabling the RestAuth<ref name="restauth" group="n" /> protocol to serialize and deserialize data in JSON<ref name="rfc 4627" group="n" />.

Introduction

Notation

The following notation standards apply to this document:

  • The terms "JSON object", "JSON string" and "JSON array" reference the respective data types in the JSON specification.

RestAuth data type mappings

String

A RestAuth string should be serialized as a JSON string.

If a string occurs as a root element in the specification, it should be wrapped in a JSON array. The JSON specification only allows objects or arrays as their root element. A JSON string as root is not a problem for most JSON libraries, but some have been known to choke.

Examples:

["username"]

or:

{"username": "password"}

Dictionary

A RestAuth dictionary should be serialized as a JSON object.

Example:

{"user": "username", "properties": {"email": "user@example.com"}}

List

A RestAuth list should be serialized as a JSON array.

Example:

["username1", "username2"]

References

<references group="n"> <ref name="rfc 4627">Crockford, D., "The application/json Media Type for JavaScript Object Notation (JSON)", RFC 4627, July 2006.</ref> <ref name="restauth">Ertl, M., et al., "RestAuth", Specification</ref> </references>

Authorship information

  • 2014, 2015, Mathias Ertl, mati@restauth.net