【问题标题】:Excel - We found extra characters at the end of JSON inputExcel - 我们在 JSON 输入的末尾发现了多余的字符
【发布时间】:2019-09-09 21:25:22
【问题描述】:

我正在尝试通过获取数据功能将我的 json 文件导入到 excel 中。执行此操作时,我收到一条错误消息,提示“我们在 JSON 输入的末尾发现了额外的字符”

我在 jsonformatter 中运行了 json 文件并得到了这条额外的信息:

第 1 行的解析错误: ...s":"1555615338756"} {"created_at":"星期四 ----------------------^ 期待 'EOF'、'}'、','、']',得到 '{'

编辑:第 1 行

{"created_at":"Thu Apr 18 19:22:18 +0000 2019","id":1118957948263206913,"id_str":"1118957948263206913","text":"阿森纳球衣看起来很奇怪。#NapoliArsenal", "来源":"\u003ca href=\"https://mobile.twitter.com\" rel=\"nofollow\"\u003eTwitter Web App\u003c/a\u003e","截断":false,"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":955479430377373696,"id_str":"955479430377373696","name": "Yash Iyer","screen_name":"MesutOziI28","location":"Bengaluru South, India","url":null,"description":"RM,Nerazzurri,BFC,RCB,bcci,rafa nadal 等等!最近进入 B99,超市!对推文表示同情!","translator_type":"none","protected":false,"verified":false,"followers_count":258,"friends_count":454,"listed_count": 0,"favourites_count":47788,"statuses_count":5318,"created_at":"Mon Jan 22 16:37:02 +0000 2018","utc_offset":null,"time_zone":null,"geo_enabled":false, "lang":"en","contribu tors_enabled":false,"is_translator":false,"profile_background_color":"F5F8FA","profile_background_image_url":"","profile_background_image_url_https":"","profile_background_tile":false,"profile_link_color":"1DA1F2","profile_sidebar_border_color" :"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"profile_image_url":"http://pbs.twimg.com/profile_images/1109886916609007616/9rAavtGh_normal.jpg" ,"profile_image_url_https":"https://pbs.twimg.com/profile_images/1109886916609007616/9rAavtGh_normal.jpg","profile_banner_url":"https://pbs.twimg.com/profile_banners/955479430377373696/1544903252","default_profile" :true,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors": null,"is_quote_status":false,"quote_count":0,"reply_count":0,"retweet_count":0,"favorite_count":0,"entities":{"hashtags":[{"text":"NapoliArsenal" ,"索引":[28,42]}],"网址":[],"user_mentions":[],"symbols":[]},"favorited":false,"retweeted":false,"filter_level":"low","lang":"en","timestamp_ms ":"1555615338756"}

【问题讨论】:

  • 呃...修复 JSON 以便验证?不完全确定 JSON 来自哪里,也不知道“获取数据函数”是什么。
  • 如果错误出现在第 1 行,那么可能有助于显示第 1 行的全部内容?你的 JSON 来自哪里?
  • 再看一遍,问题是你必须在没有分隔符的情况下使用花括号...5338756"} {"created_。根据第 1 行的开头,您很可能需要在结尾和大括号之间使用逗号
  • @ScottHoltzman 将其作为回答;鉴于上下文,这是我能看到的唯一答案...应该能够将其从未回答列表中删除
  • 似乎有Relaxed JSON 样本。我猜 get data 函数需要标准 JSON。

标签: json excel parsing


【解决方案1】:

我必须进行两项更改才能完成这项工作:将 json 正文更改为 Pascal 大小写表示法,即使它是 chrome 有效负载中的 Camel 大小写 ,其次我返回一个简单的字符串来验证服务是否正常工作 - 一旦我将其更改为一个对象(作为 json 格式的响应),这解决了我遇到的错误。

【讨论】:

    【解决方案2】:

    永远老了,但我试图通过 Power Query 将 AWS CloudCheckr JSON 摄取到 Excel 中,并得到“我们在 JSON 输入的末尾发现了额外的字符。”

    终于在https://jsonformatter.org/ 的帮助下发现,一些数据是以True 提供的——没有引号,这是Excel PQ 需要的。用:"True", 简单地查找/替换:True, 就可以了。

    说真的,微软,你发现布尔值时不认识它? Excel 应该没有问题。

    【讨论】:

      【解决方案3】:

      答案在错误信息中:

      期望 'EOF'、'}'、','、']',得到 '{'

      查看{ 的出现位置,注意在其前面是}。 JSON 在结束卷曲 } 之后没有分隔符,因此无法处理它,因为它正在寻找以下内容之一:

      • EOF
      • }
      • ,
      • ]

      在这种情况下,它很可能需要,。如果它是一个项目数组,它也可能需要],。如果这些都不能解决问题,您将需要发布 JSON 的整个第 1 行。

      【讨论】:

      • 感谢您的快速回复,以及您为帮助我到目前为止所做的努力。建议的修复都不起作用,因此我将整个第 1 行编辑为问题@ScottHoltzman
      • @SimenL.N - 当我将您的 JSON 放入 jsonformatter.org 时,它会完美验证。它也与您显示的错误不匹配。 s":"1555615338756"} {"created_at"... 但有一个线索是它可能正在生成 2 组 JSON,因为结束之后就是一个新的开始
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多