Skip to content

0.7 JSON Data Structures

Kurtis Nusbaum edited this page Jun 26, 2013 · 28 revisions

Back to 0.7 API #JSON Data Structures The following is a list of commonly used UDJ JSON data structures.

User

{
  "id" : Id of user (string),
  "username" : User name of the user (string),
  "first_name" : Users first name (string),
  "last_name" : Users last name (string)
}

Player

{
  "id" : unique player id (string),
  "name": name of player (string),
  "owner" : User JSON Object representing the owner of the player,
  "has_password" : true if the player has a password, false otherwise,
  "location" : { (optional)
    "latitude" : the latitude of the location of the player (number),
    "longitude" : the longitude of the location of the player (number),
    "address" : address of player (string),
    "locality" : Locality/City of player (string),
    "region" : State, Region, or Providence of player (string),
    "postal_code" : postal code of player (string),
    "country" : country of player (string)
  },
  "sorting_algo" : A Sorting Algorithm JSON object representing the sorting algorithm this player is using for the playlist,
  "num_active_users": Currently how many active users are participating with this player (number),
  "size_limit" : The maximum number of active participants that can be in a player at a given time. Note: if the player has no size limit, attribute will not be present (number).
  "state" : One of {"play" | "pause" | "inactive"}.
  "volume" : An integer in the range `0 <= x <= 10 `
}

Player Permissions

{
  "participate_with_player" : JSON array of group names,
  "set_player_state" : JSON array of group names,
  "control_volume" : JSON array of group names,
  "set_sorting_algorithm" : JSON array of group names,
  "set_location" : JSON array of group names,
  "set_password" : JSON array of group names,
  "kick_users" : JSON array of group names,
  "ban_users" : JSON array of group names,
  "active_playlist_mod_current_song" : JSON array of group names,
  "active_playlist_remove_songs" : JSON array of group names,
  "active_playlist_add_songs" : JSON array of group names,
  "active_playlist_upvote" : JSON array of group names,
  "active_playlist_downvote" : JSON array of group names,
  "enable_library" : JSON array of group names,
  "disable_library" : JSON array of group names,
  "modify_permissions" : JSON array of group names,
  "create_event" : JSON array of group names
  "host_event" : JSON array of group names
  "modify_event" JSON array of group names
  "create_song_set" : JSON array of group names,
  "modify_others_song_set" : JSON array of group names,
}

Permission Group

{
  "id" : id of group,
  "name" : name of group,
  "users" : JSON array of user ids
}

Library

{
  "id" : id of library (string),
  "name" : name of library (string),
  "description" : short description of library (string),
  "pub_key" : 2048 bit RSA public key for this library,
  "read_permission" : "none" | "owner" | "user" | "public",
  "write_perimssion" : "none" | "owner" | "user" | "public",
  "owner" : If the library has an owner this is a User JSON object, if the library has no owner, this is an empy JSON object,
  "is_official" : true if the library is officially verified by the server, false otherwise
}

Library Entry

{
  "id" : id of library entry (string),
  "library_id" id of the library to which this library entry belongs (string),
  "title" : name of the song (string),
  "artist" : name of the artist (string),
  "album" : name of album (string),
  "track" : number of track (number),
  "genre" : genre of the song (string),
  "duration" : duration of song in seconds (number)
}

Simple Library Entry

{
  "id" : id of library entry (string),
  "library_id" id of the library to which this library entry belongs (string),
}

Active Playlist Entry

{
  "song" : LibraryEntry JSON object,
  "upvoters" : A JSON array of User objects who have upvoted this song,
  "downvoters" : A JSON array of User objects who have downvoted this song,
  "time_added" : Time the entry was added (string),
  "adder" : User JSON Object representing the user who added the player,
}

Played Active Playlist Entry

{
  "song" : LibraryEntry JSON object,
  "upvoters" : A JSON array of User objects who have upvoted this song,
  "downvoters" : A JSON array of User objects who have downvoted this song,
  "time_added" : Time the entry was added (string),
  "time_played" : Time the entry started playing (string),
  "adder" : User JSON Object representing the user who added the player
}

Song Set

{
  "id" : id of Song Set (string),
  "name" : Name of song set (string),
  "description" : a short description of the song set (string),
  "songs" : a JSON Array of Library Entry JSON Objects,
  "owner" : a User JSON Object representing the owner of the song set,
  "date_created" : The date the song set was created (string)
}

Sorting Algorithm

{
  "id" : id of sorting algorithm (string),
  "name" : name of sorting algorithm (string),
  "description" : short description of how the sorting algorithm works (string)
  "uses_adder" : a boolean indicating whether or not this algorithm takes the song adder into account when sorting,
  "uses_time_added" : a boolean indicating whether or not this algorithm takes time added into account when sorting,
  "uses_upvotes" : a boolean indicating whether or not this algorithm takes upvotes into account when sorting,
  "uses_downvotes" : a boolean indicating whether or not this algorithm takes downvotes into account when sorting,
  "uses_duration" : a boolean indicating whether or not this algorithm takes song duration into account when sorting
}

Event

{
  "id" : id of event (string),
  "name" : name of event,
  "player_id" : id of player the event will be on,
  "start_time" : start time of event,
  "end_time" end time of event
}