如何访问从 API 返回的 hash/object?
How to access a hash/object returned from API?
我将 API 称为 returns 大 hash/object。我有两个问题:
为了引用该散列的 keys/values(例如,在对话中),我必须将散列转换为结构吗? (或者有没有办法访问对象"directly.")
如果我确实必须将散列转换为 Bixby 结构,是否有某种方法可以通过编程方式实现?
现在,我已经为对象中的所有键创建了一大堆原语,然后创建了一个将所有这些原语作为属性的结构。我希望我遗漏了什么,因为返回的散列可能有 100 个键。
In order to refer to the keys/values of that hash (e.g., in a dialogue), do I have to convert the hash into a structure? (Or is there a way to access the object "directly.")
是的,如果您想这样做,您必须定义一个 structure
。
If I do have to convert the hash into a Bixby structure, is there some way to do that programatically?
目前没有,没有。为了避免为哈希中的每个字段创建 100 多个不同模型的痛苦,您可以使用 visibility
键来重用概念。
例如,
structure (Group) {
description (Represents a group.)
property (id) {
type (viv.core.Text) // Normally you can't have two properties of the same type.
min (Required) max (One)
visibility (Private) // But with this key, the planner cannot see this concept and won't be confused.
}
property (name) {
type (viv.core.Text)
min (Required) max (One)
visibility (Private)
}
(more properties here)
}
另一种选择是仅在 JavaScript 中生成对话,并为您想说的任何内容提供一个 "dialog" 字段。这可能是要走的路,除非您有特定需要在模型中模拟出 100 个不同的字段并希望在规划器中使用它们。
我将 API 称为 returns 大 hash/object。我有两个问题:
为了引用该散列的 keys/values(例如,在对话中),我必须将散列转换为结构吗? (或者有没有办法访问对象"directly.")
如果我确实必须将散列转换为 Bixby 结构,是否有某种方法可以通过编程方式实现?
现在,我已经为对象中的所有键创建了一大堆原语,然后创建了一个将所有这些原语作为属性的结构。我希望我遗漏了什么,因为返回的散列可能有 100 个键。
In order to refer to the keys/values of that hash (e.g., in a dialogue), do I have to convert the hash into a structure? (Or is there a way to access the object "directly.")
是的,如果您想这样做,您必须定义一个 structure
。
If I do have to convert the hash into a Bixby structure, is there some way to do that programatically?
目前没有,没有。为了避免为哈希中的每个字段创建 100 多个不同模型的痛苦,您可以使用 visibility
键来重用概念。
例如,
structure (Group) {
description (Represents a group.)
property (id) {
type (viv.core.Text) // Normally you can't have two properties of the same type.
min (Required) max (One)
visibility (Private) // But with this key, the planner cannot see this concept and won't be confused.
}
property (name) {
type (viv.core.Text)
min (Required) max (One)
visibility (Private)
}
(more properties here)
}
另一种选择是仅在 JavaScript 中生成对话,并为您想说的任何内容提供一个 "dialog" 字段。这可能是要走的路,除非您有特定需要在模型中模拟出 100 个不同的字段并希望在规划器中使用它们。