gpt4 book ai didi

javascript - 错误 : 3 INVALID_ARGUMENT: Cannot convert an array value in an array value in Firestore admin

转载 作者:行者123 更新时间:2023-12-01 15:26:55 25 4
gpt4 key购买 nike

我正在尝试在我的 firstore 数据库中保存使用 twitter api 检索到的多个推文对象,但出现此错误:

Error: 3 INVALID_ARGUMENT: Cannot convert an array value in an array value


以下是样本 JSON对象:所有推文对象都与此类似
TweetObj: {
"created_at": "Wed Feb 12 15:17:24 +0000 2020",
"id": 1227612675334660000,
"id_str": "1227612675334660099",
"full_text": "Writing online is a superpower.\n\nHere’s a list of people who should start writing online.\n\n1. The Niche Hobbyist\n\nThe Internet rewards people with obscure interests. Writing online will help you find other like-minded hobbyists who you wouldn’t be able to find in real-life.",
"truncated": false,
"display_text_range": [
0,
274
],
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [],
"urls": []
},
"source": "<a href=\"http://twitter.com/download/iphone\" rel=\"nofollow\">Twitter for iPhone</a>",
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"user": {
"id": 240049622,
"id_str": "240049622",
"name": "David Perell",
"screen_name": "david_perell",
"location": "New York",
"description": "\"The Writing Guy\" | I tweet about business, online learning, and Internet writing | My Podcast: | My writing school: ,
"url": "",
"entities": {
"url": {
"urls": [
{
"url": ,
"expanded_url": "http://www.perell.com/",
"display_url": "perell.com",
"indices": [
0,
23
]
}
]
},
"description": {
"urls": [
{
"url": "",
"expanded_url": "http://Perell.com/podcast",
"display_url": "Perell.com/podcast",
"indices": [
96,
119
]
},
{
"url": "",
"expanded_url": "http://writeofpassage.school",
"display_url": "writeofpassage.school",
"indices": [
141,
164
]
}
]
}
},
"protected": false,
"followers_count": 89464,
"friends_count": 763,
"listed_count": 1539,
"created_at": "Wed Jan 19 01:41:27 +0000 2011",
"favourites_count": 51075,
"utc_offset": null,
"time_zone": null,
"geo_enabled": true,
"verified": false,
"statuses_count": 21700,
"lang": null,
"contributors_enabled": false,
"is_translator": false,
"is_translation_enabled": false,
"profile_background_color": "C0DEED",
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
"profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
"profile_background_tile": false,
"profile_image_url": "http://pbs.twimg.com/profile_images/913816689892044800/rF7O3Bfz_normal.jpg",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/913816689892044800/rF7O3Bfz_normal.jpg",
"profile_banner_url": "https://pbs.twimg.com/profile_banners/240049622/1543613054",
"profile_link_color": "129CE6",
"profile_sidebar_border_color": "C0DEED",
"profile_sidebar_fill_color": "DDEEF6",
"profile_text_color": "333333",
"profile_use_background_image": true,
"has_extended_profile": true,
"default_profile": false,
"default_profile_image": false,
"following": true,
"follow_request_sent": false,
"notifications": true,
"translator_type": "none"
},
"geo": null,
"coordinates": null,
"place": {
"id": "01a9a39529b27f36",
"url": "https://api.twitter.com/1.1/geo/id/01a9a39529b27f36.json",
"place_type": "city",
"name": "Manhattan",
"full_name": "Manhattan, NY",
"country_code": "US",
"country": "United States",
"contained_within": [],
"bounding_box": {
"type": "Polygon",
"coordinates": [
[
[
-74.026675,
40.683935
],
[
-73.910408,
40.683935
],
[
-73.910408,
40.877483
],
[
-74.026675,
40.877483
]
]
]
},
"attributes": {}
},
"contributors": null,
"is_quote_status": false,
"retweet_count": 357,
"favorite_count": 2145,
"favorited": false,
"retweeted": false,
"lang": "en"
}
以上是给出错误的确切对象
在上面的代码片段中,参数线程是 array包含多个推文对象,就像前面描述的那样。
帮助将不胜感激。

最佳答案

您可以尝试透明地序列化/反序列化您的推文,以便:

  • 在保存到 Firestore 之前将所有数组转换为对象
  • 从 firestore
  • 检索记录后,将所有键为数字的对象转换为数组

    根据应该索引和查询的数据,您还可以使用 JSON.stringify()在 Firestore 不支持的结构的某些部分上。

    关于javascript - 错误 : 3 INVALID_ARGUMENT: Cannot convert an array value in an array value in Firestore admin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61888435/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com