REP-003 - JSON serialization

From RestAuth
Jump to navigation Jump to search

This document specifies REP-003 - JSON serialization, enabling the RestAuth[n 1] protocol to serialize and deserialize data in JSON[n 2].

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

  1. Ertl, M., et al., "RestAuth", Specification
  2. Crockford, D., "The application/json Media Type for JavaScript Object Notation (JSON)", RFC 4627, July 2006.

Authorship information

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