Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze the BOM problem by json

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Json how to analyze the BOM problem, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Json (javascript object notation) is a subset of javascript (standard ECMA-262 3rd Edition-December 1999) that uses a completely language-independent text format. The data in this format is small in size and easy to parse between systems. various languages have their own methods for parsing data in json format.

But if you write a file in json format in windows environment, then use Python or golang to read the file. When the read string is parsed by json, the error can't decode byte in position 0: invalid continuation byte is often reported. When you select utf-8 encoding under windows, the utf-8 form with BOM is used, and "\ xef\ xbb\ xbf" is added to the header of the file by default.

The string read through the file is'\ xef\ xbb\ xbf {xef\ xbb\ xbf', which is definitely not in line with the definition of json format, and is the standard json format only when\ string\ string\ string is removed.

The solution can be to save the file in utf-8 without BOM format. If the program itself runs in the Linux environment, there will be no BOM problems if you can edit the json format file directly in the Linux environment.

If you have edited json format files in windows environment, such as configuration file config.json, if you parse an error, the first thing you should consider is BOM.

This is the answer to the question about how json parses BOM. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report