在 Power Query M 中动态引用 JSON 节点
Dynamically referring to JSON node in Power Query M
我有一个从 JSON 文档中提取节点的函数,如下所示:
...
Json = GetJson(Url),
Value = Json[#"values"]
值对应于 JSON 文档中的实际节点。
我想概括这段代码并提供节点名称作为变量,如:
let myFunc = (parentNodeName as text) =>
...
Json = GetJson(Url),
Value = Json[parentNodeName]
但是出现此错误:
An error occurred in the ‘myFunc’ query. Expression.Error: The field 'parentNodeName' of the record wasn't found.
如何动态引用 JSON 节点?
尝试
(Json, parentNodeName ) =>
let
...
Value = Record.Field(Json,parentNodeName)
in Value
示例代码:
let Json = Json.Document(Web.Contents("http://soundcloud.com/oembed?url=http%3A//soundcloud.com/forss/flickermood&format=json")),
Value=myFunc(Json,"title")
in Value
和我的函数:
(Json, parentNodeName ) =>
let
Value = Record.Field(Json,parentNodeName)
in Value
我有一个从 JSON 文档中提取节点的函数,如下所示:
...
Json = GetJson(Url),
Value = Json[#"values"]
值对应于 JSON 文档中的实际节点。
我想概括这段代码并提供节点名称作为变量,如:
let myFunc = (parentNodeName as text) =>
...
Json = GetJson(Url),
Value = Json[parentNodeName]
但是出现此错误:
An error occurred in the ‘myFunc’ query. Expression.Error: The field 'parentNodeName' of the record wasn't found.
如何动态引用 JSON 节点?
尝试
(Json, parentNodeName ) =>
let
...
Value = Record.Field(Json,parentNodeName)
in Value
示例代码:
let Json = Json.Document(Web.Contents("http://soundcloud.com/oembed?url=http%3A//soundcloud.com/forss/flickermood&format=json")),
Value=myFunc(Json,"title")
in Value
和我的函数:
(Json, parentNodeName ) =>
let
Value = Record.Field(Json,parentNodeName)
in Value