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

Step 5: Categories Recipe: MatchList Parameters

Let's continue configuring the Categories recipe by populating the matchlist and keyDataType parameters.

matchList Parameter

The purpose of the matchList parameter is to select specific properties from the category query result and map them to the Fire App Builder content model.

In the sample app in Fire App Builder, the value for the Categories recipe is StringKey@mName.

Here's how this syntax works. On the left of the @ symbol you put the property you want to target in the query result (StringKey selects the list of strings). On the right of the @ symbol you put the Fire App Builder element you want to map the property to (mName).

For the Categories recipe, your matchList parameter should map your feed's categories to mName.

In the Fire App Builder sample app, since the query result is a list of strings, StringKey is used to match the strings.

Supposing the result is a list of strings:

Text='Technology'
Text='Gadgets'

To match the text contents and map them to the category element in the Fire App Builder UI, you would use the following syntax:

StringKey@mName

If your query result looked like this:

<list>
<title>My category title</title>
</list>

Then you would map the category title like this:

/list/title@mName

The forward slash (/) takes you one level deeper in the XML nodes. </div> </div> </div>

Instead of just a list of strings, suppose the result set from your query contained a JSON object such as the following:

"list": { "title" : "My category title" }

To match on My category title and convert it to mName, you would use the following:

list/title@mName

Use the forward slash (/) to go deeper in object levels (just like with XPath). In this case, title is one object below list, which is one object below the root. After moving past these two levels, the result is simply the category name.

keyDataType Parameter

Fire App Builder needs to know which media items should be grouped with the selected categories. The keyDataType parameter identifies the media items that are related to a category. This parameter is used for the Category recipe and later passed into a variable in the Contents recipe.

The Fire App Builder query result is a list of strings, so StringKey@keyDataPath is used to target the media items and associate them with the category. If your result is also a list of strings, then you would use the default:

"keyDataType": "StringKey@keyDataPath"

However, suppose your media objects were listed inside an assets node that in turn was nested inside a container node, like this:

"container": {
    "assets": [
    "5825652561001",
    "5825652558001",
    "5825652569001",
    "5873045223001",
    ]
}

or this:

<container>
  <assets>
    <id>5825652561001</id>
    <id>5825652558001</id>
    <id>5825652569001</id>
    <id>5873045223001</id>
  </assets>
</container>

To get the media objects, you would write the SYNTAX like this:

container/assets@keyDataPath

Similar to the matchList parameter, the keyDataType query does not use Jayway JsonPath syntax either. Instead, you match each node by writing the node name followed by / to move into the next level. container/assets matches all the items at this level.

On the right of the ampersand @, the keyDataPath key is how these media objects are stored and used by Fire App Builder. The @keyDataPath helps match up the items with the Fire App Builder content model.

Next Steps

Now that you've finished configuring the categories recipe, it's time to start configuring the contents recipe. See Step 6: Set Up the Contents Recipe.


Last updated: Aug 03, 2018