繁体   English   中英

Google Apps 脚本 JSON.parse 将 URLFetchAPP 中的所有“:”(冒号)替换为 ="(等号)

[英]Google Apps Script JSON.parse replaces all “:” (colon) in a URLFetchAPP with =" (equals sign)

Google App Scripts 上 URLFetchApp 的 JSON.parse 将字符串中的所有冒号更改为等号。 它与我认为 JSON.parse 应该做的完全相反。 我尝试在不同的地方解析相同的字符串,甚至做了 node.js fetch 和 output 都可以。 似乎是 Google AppScript 的问题

例子:

代码

var res = UrlFetchApp.fetch(url, options)
var text = res.getContentText()
var json = JSON.parse(text)
Logger.log(text)
Logger.log(json)

日志:

{"status":{"timestamp":"2021-03-24T16:01:13.657Z","error_code":0,"error_message":null,"elapsed":20,"credit_count":1,"notice":null},"data":[{"id":1,"symbol":"BTC","name":"Bitcoin","amount":1,"last_updated":"2021-03-24T16:00:03.000Z","quote":{"GBP":{"price":41091.43869808855,"last_updated":"2021-03-24T16:00:21.000Z"}}}]}

{status={elapsed=20.0, timestamp=2021-03-24T16:01:13.657Z, error_message=null, notice=null, credit_count=1.0, error_code=0.0}, data=[{amount=1.0, symbol=BTC, last_updated=2021-03-24T16:00:03.000Z, id=1.0, name=Bitcoin, quote={GBP={price=41091.43869808855, last_updated=2021-03-24T16:00:21.000Z}}}]}

这不是问题,这是一个特点。

而不是Logger.log(json)使用Logger.log(JSON.stryngify(json))

有关的

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM