Step 6: Set Up the Contents Recipe
When you configured your categories, you configured the general groupings for your media. In this step you will map your feed's content (the titles, descriptions, images, video URLs, and so on) to the Fire App Builder content model. For an overview to recipe configuration, see Recipe Configuration Overview.
Configure the Contents Recipe
-
Open the <project name>ContentsRecipe.json file (located in app > assets > recipes).
The default content recipe configuration looks like this:
{ "cooker": "DynamicParser", "format": "json", "model": "com.amazon.android.model.content.Content", "translator": "ContentTranslator", "modelType": "array", "query": "$[?(@.categories[0] in [$$par0$$])]", "matchList": [ "title@mTitle", "id@mId", "description@mDescription", "videoURL@mUrl", "imgURL@mCardImageUrl", "imgURL@mBackgroundImageUrl", "channel_id@mChannelId" ] } -
Configure the file's values as explained in the following table.
Note: Because thequeryandmatchListparameters are more complex, their configurations are explained in the topics that follow — Contents Recipe: query Parameter and Contents Recipe: matchlist Parameter.Key Description cookerDefines which utility will take the parameters defined in the recipe and run the logic. In other words, the cooker "cooks" the recipe. Leave it at the default value:
DynamicParser.formatSpecifies the data format for the incoming data feed. Options are
jsonorxml.translatorSpecifies whether translation or reflection is used when converting your feed's objects to the Fire App Builder content model. Translation is faster and recommended. To use translation, leave the value at the default:
ContentTranslator. If you want to use reflection instead, remove thetranslatorparameter altogether from the recipe.modelSpecifies the content model for the data. The content model provides the structure for your content and maps it into the Fire App Builder UI. Leave it at the default:
com.amazon.android.model.content.Content.modelTypeSpecifies whether the feed is an array or a single object. Available options are
arrayorsingle. Almost all feeds arearray. For example, if your JSON feed is enclosed within square brackets, or your XML feed has nested angle brackets, choosearray. If your feed is structured as a single object, choosesingle.queryA query used to return content items from your media feed. The syntax of the query depends on the structure of your feed. You will need to construct the right query to get your content items. For JSON feeds, use Jayway JsonPath syntax for the query syntax. For XML feeds, use XPath expressions for the query syntax. Leave this field's value as is for now. You will configure it in the next step: Contents Recipe: query Paramater Parameter.
queryResultTypeIf the result from
queryparameter returns a list of strings, include thisqueryResultTypeparameter and set it equal to[]$. If the query's result is an object (a map), omit this parameter. (Fire App Builder needs to know the result type because it will needs to push an object into a Java hashmap.)matchListThe query that you defined in the
queryparameter returns a result. This result needs to be mapped from your feed's names to the names Fire App Builder uses in its content model. ThematchListparameter maps the results from the query to the name for media categories in Fire App Builder. Leave this field's value as is for now. You will configure it in an upcoming step: Contents Recipe: matchlist Parameter.
Next Steps
Now that you've configured the basic properties in the contents recipe, let's dig into the query parameters. Continue to the next step: Contents Recipe: query Parameter.
Last updated: Apr 06, 2017

