开发者控制台
感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

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

  1. 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"
        ]
    }
    
  2. Configure the file's values as explained in the following table.

    Key Description

    cooker

    Defines 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.

    format

    Specifies the data format for the incoming data feed. Options are json or xml.

    translator

    Specifies 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, simply leave the value at the default: ContentTranslator. If you want to use reflection instead, remove the translator parameter altogether from the recipe.

    model

    Specifies 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.

    modelType

    Specifies whether the feed is an array or a single object. Available options are array or single. Almost all feeds are array. For example, if your JSON feed is enclosed within square brackets, or your XML feed has nested angle brackets, choose array. If your feed is structured as a single object, choose single.

    query

    A 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.

    queryResultType

    If the result from query parameter returns a list of strings, include this queryResultType parameter 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.)

    matchList

    The query that you defined in the query parameter 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. The matchList parameter 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