ドキュメント

サポート

Remote Config

Remote Config

Templates

Use JSON Schema templates to define shapes for Remote Config keys.
読み終わるまでの所要時間 4 分最終更新 1ヶ月前

Templates can be used in Remote Config to define a shape for JSON keys. This enables validation for the data within your game configuration and ensures that any updates made are in the shape that your game client expects. To define a Template, you create a JSON schema to define the constraints of the data and attach it to one or more keys. Any future updates made against those keys in Remote Config, Game Overrides or the Remote Config API must meet the constraints of the schema defined in the Template. Templates can be used to add another layer of safety to the live updates made in your game. For example, a developer might want to configure Templates with constraints as part of their initial implementation and then hand them over to their live operations team to make updates safely.

Getting Started

To create a Template and add it to an existing Remote Config key, complete the following steps:
  1. Navigate to Remote Config, then Templates in the sidebar
  2. Create a new Template using the Create Template button
  3. Enter the schema (using the JSON Schema revision 7 format) for your template into the JSON editor field
    1. The $id field is required and must be a unique URI. The title field is also required and should be used as a human-readable reference to the Template. A description field is optional and can be used to provide a longer description to your colleagues.
  4. Navigate to the Config page and create a new JSON key or edit an existing one
  5. Select the Template for this key from the dropdown
  6. Update the key’s value to ensure it matches the Template
  7. Save the key

Top tip

You can use an online schema generator - such as JSON to JSON schema - to take an existing key’s JSON and create a new schema as a starting point.

Use cases

Templates can be used to achieve a variety of use cases by using the constraints provided by JSON Schema revision 7. You can find some example use cases, as well as links to the relevant reference, below.

Use case

Relevant reference

Make sure a mission always has a name and ID, and the ID is always a number.Required properties and types.
Set a maximum length for the name of your seasonal event to make sure it doesn’t break into multiple lines in the game UI.String formatting.
Make sure the dates for in-game messages are ISO8601 compliant and the support contact numbers are a US phone number.Built-in string formats and regular expressions.
Set a maximum value for your level difficulty and make sure it’s always a multiple of 5.Number ranges and multiples.
Make sure the rewards for your seasonal event are always a specific string.Enumerated values.
Ensure that when you have a mission object defined, you also always have a reward defined.Conditional validation.

Examples

Whilst Templates can be used to define a shape for any change to your game, the examples below should help you get started and can be tweaked to your needs.

Required properties and types for an array of missions

Below is a schema for a single-level key that configures a number of missions where each must have a name string and a number ID.
{ "$id": "#missions", "title": "Missions", "description": "The missions in the game.", "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "ID": { "type": "number" } }, "required": ["name", "ID"] }}

String formatting for in-game messages

Setting the maximum length for a string, a date format and using a regular expression to check the format of a string.
{ "$id": "#in-game-inbox", "title": "In-Game Inbox", "description": "The in-game inbox.", "type": "object", "properties": { "messageID": { "type": "number" }, "messageContent": { "type": "string", "maxLength": 500 }, "sendDate": { "type": "string", "format": "date-time" }, "supportContactNumber": { "type": "string", "pattern": "^\\+1\\s\\([0-9]{3}\\)\\s[0-9]{3}-[0-9]{4}$" } }, "required": ["messageID", "messageContent", "sendDate", "supportContactNumber"]}

Number formatting for level difficulty

Setting a minimum and maximum number for a level difficulty field, as well as ensuring it’s always a multiple of 5.
{ "$id": "#levels", "title": "Levels", "description": "The levels in the game.", "type": "array", "items": { "type": "object", "properties": { "levelID": { "type": "number" }, "levelName": { "type": "string" }, "difficulty": { "type": "number", "minimum": 0, "maximum": 100, "multipleOf": 5 } }, "required": ["levelID", "levelName", "difficulty"] }}

Using an enumerated list for a seasonal event reward

{ "$id": "#seasonal-event", "title": "Seasonal Event", "description": "The seasonal event.", "type": "object", "properties": { "eventID": { "type": "number" }, "eventName": { "type": "string" }, "description": { "type": "string" }, "reward": { "type": "string", "enum": ["Gold Coins", "Special Item", "Bonus Points", "Exclusive Access"] } }, "required": ["eventID", "eventName", "description", "reward"]}

Conditionally requiring a mission details field when a mission is defined

This schema ensures that the mission details object is required whenever a mission type is defined - and the same for rewards.
{ "$id": "#missions", "title": "Missions", "description": "The missions in the game.", "type": "object", "properties": { "missionType": { "type": "string", "enum": ["Combat", "Exploration", "Puzzle"] }, "missionDetails": { "type": "object" }, "reward": { "type": "object", "properties": { "rewardType": { "type": "string", "enum": ["Item", "Currency", "Experience"] }, "rewardDetails": { "type": "object" } } } }, "dependentRequired": { "missionType": ["missionDetails"], "rewardType": ["rewardDetails"] }}