jsonc:带有注释的JSON!

  • l5_358904
    了解作者
  • 1020.3KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-20 05:15
    上传日期
带有注释的JSON! JSONC是JSON的超集,支持注释。 JSON格式的文件对人类是可读的,但是缺少注释会降低可读性。 使用JSONC,您可以使用块( /* */ )和单行( // )注释来描述功能。 Microsoft VS Code在其配置文件(例如settings.json , keybindings.json , launch.json等)中也使用此格式。 该套餐提供什么 JSONC for Go提供了将JSONC转换和解组为纯JSON的功能。 它还提供了从磁盘读取JSONC文件并返回JSONC和相应的JSON编码以进行操作的功能。 但是,它仅提供一种单向转换。 也就是说,您无
jsonc-master.zip
  • jsonc-master
  • carbon.png
    130.9KB
  • jsonc_test.go
    5.1KB
  • translator.go
    2.6KB
  • DOCUMENTATION.md
    2KB
  • CONTRIBUTING.md
    1.1KB
  • .travis.yml
    150B
  • LICENSE
    1KB
  • README.md
    1.8KB
  • jsonc.png
    895.1KB
  • CODE_OF_CONDUCT.md
    3.3KB
  • .gitignore
    192B
  • jsonc.go
    2KB
内容介绍
# ![jsonc](jsonc.png) <p align="center"> <i>JSON with comments for Go!</i> <br> <i><a href="https://travis-ci.com/muhammadmuzzammil1998/jsonc" target="_blank" rel='nofollow' onclick='return false;'><img src="https://travis-ci.com/muhammadmuzzammil1998/jsonc.svg?branch=master" alt="travisci"></a></i> </p> JSONC is a superset of JSON which supports comments. JSON formatted files are readable to humans but the lack of comments decreases readability. With JSONC, you can use block (`/* */`) and single line (`//`) comments to describe the functionality. Microsoft VS Code also uses this format in their configuration files like `settings.json`, `keybindings.json`, `launch.json`, etc. ![jsonc](carbon.png) ## What this package offers **JSONC for Go** offers ability to convert and unmarshal JSONC to pure JSON. It also provides functionality to read JSONC file from disk and return JSONC and corresponding JSON encoding to operate on. However, it only provides a one way conversion. That is, you can not generate JSONC from JSON. Read [documentation](DOCUMENTATION.md) for detailed examples. ## Usage ### `go get` it Run `go get` command to install the package. ```sh $ go get muzzammil.xyz/jsonc ``` ### Import jsonc Import `muzzammil.xyz/jsonc` to your source file. ```go package main import ( "fmt" "muzzammil.xyz/jsonc" ) ``` ### Test it Now test it! ```go func main() { j := []byte(`{"foo": /*comment*/ "bar"}`) jc := jsonc.ToJSON(j) // Calling jsonc.ToJSON() to convert JSONC to JSON if jsonc.Valid(jc) { fmt.Println(string(jc)) } else { fmt.Println("Invalid JSONC") } } ``` ```sh $ go run app.go {"foo":"bar"} ``` ## Contributions Contributions are welcome but kindly follow the Code of Conduct and guidelines. Please don't make Pull Requests for typographical errors, grammatical mistakes, "sane way" of doing it, etc. Open an issue for it. Thanks!
评论
    相关推荐