When creating your product list for GameMaker: Studio you would normally do so using ds_lists and ds_maps along with the function iap_activate(). However there exists a second path through iap_activate() which lets you specify your set of products through a JSON string.
iap_activate(JSON_string);
This JSON string is handled using the same format required for the amazon.sdktester.json file as used when testing Amazon purchasing for Android. No other store uses a JSON format and so this approach will minimise effort for developers targeting this store as well as providing a fairly readable approach to specifying their products.
As such, the "product_id" is the object name for a product as opposed to part of an object’s set of members as you might expect (see http://www.json.org/ for reference)
The JSON shown below is a simple example of how this would be set up for a single product:
{
"noads": {
"itemType": "Durable",
"price": 0.99,
"title": "No Ads",
"description": "Remove advertising"
}
}
With two products it would change like this:
{
"noads": {
"itemType": "Durable",
"price": 0.99,
"title": "No Ads",
"description": "Remove advertising"
},
"godmode": {
"type": "Consumable",
"price": 0.99,
"title": "God Mode",
"description": "Buy god mode credits"
}
}
NOTE:
- Always use an outside set of curly braces for the JSON data. Do not think “I don’t see the point of those, they won’t matter”.
- Price can be a number or a string.
- You can use “itemType” or “type” to specify the “type” to allow users to use the Amazon form as is and any additional object members will be ignored.
- The value of the “type” is not case sensitive.
- It is recommended you validate your JSON at http://jsonlint.com/
- You can load your JSON from an included file or have it as a part of a script (hint: use single quotes around the data).
- You can use your amazon.sdktester.json test file without modification with GameMaker: Studio.
- When targeting Google Play, Amazon, iOS, or Mac where only the list of product IDs is required you can setup the JSON to just be:
{
"noads" : {},
"godmode" : {},
"test001" : {},
"test002" : {},
"test003" : {}
}