我试图通过在逗号前后放置双引号 (") 来转义字符串中的逗号,但它也没有用。 这是 M 中的 let 函数,用于调用 API 并传递变量值。问题是对于状态字段,它不允许我使用逗号并导致脚本中断。有什么好的逃生方法吗?
() =>
let
url = api_url,
authorization ="Bearer " & api_key,
variables_values = Text.Format(
"""variables"": {
""state"": ""["""MA"""," ""ME""]"",
""property_use_code_mapped"": ""44""
}",
[
]
),
request_body = Text.Format("{""query"":
""query taxassessorQuery($state: [String!], $property_use_code_mapped:[bigquery_decimal!]) {
tax_assessor(
limit: #[records_per_page]
where: {
property_use_code_mapped: {_in: $property_use_code_mapped}
state: {_in: $state}
} order_by:{tax_assessor_id:asc})
{
tax_assessor_id
address
city
state
zip
latitude
longitude
year_built
}
}"",
#[variables_values]
}",
[
records_per_page = 10,
variables_values = #"variables_values"
]
),
request_cleaned = Text.Clean(request_body),
request_encoded_as_binary = Text.ToBinary(request_cleaned),
json_response = Json.Document(Web.Contents(url,[
Headers = [#"Authorization"=authorization,#"Content-Type"="application/json"],
Content = request_encoded_as_binary
] )),
data = json_response[data]
in
data
你想得到这个输出吗?
“变量”:{ “状态”:“[“MA”,“ME”]”, “property_use_code_mapped”:“44”}
使用
let variables_values =
"""variables"": {
""state"": ""[""MA"",""ME""]"",
""property_use_code_mapped"": ""44""}",