• Stars
    star
    183
  • Rank 210,154 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JSON with comments for Go!

jsonc

JSON with comments for Go!
GitHub Actions

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 (// of #) 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

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 for detailed examples.

Usage

go get it

Run go get command to install the package.

$ go get muzzammil.xyz/jsonc

Import jsonc

Import muzzammil.xyz/jsonc to your source file.

package main

import (
  "fmt"

  "muzzammil.xyz/jsonc"
)

Test it

Now test it!

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")
  }
}
$ 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!

Contributors

More Repositories

1

catsay

A program that generates pictures of a cat holding a sign with a message.
Go
96
star
2

Log-mailer

Log mailer is a program I made to email log files.
Go
46
star
3

OctoCSS

Minimalistic "Fork me on GitHub"
CSS
29
star
4

dsongo

Encoding, decoding, marshaling, unmarshaling, and verification of the DSON (Doge Serialized Object Notation)
Go
24
star
5

headless-mermaid

A mermaid.js handler for server-side rendering for Node.js.
JavaScript
22
star
6

ace

Resource update notifier
Go
7
star
7

SmartText

Protect your messages with 256-bit encryption.
PHP
4
star
8

Page-Hash

Generates hashes of online resources
JavaScript
4
star
9

BitcoinBot

A discord bot to check Bitcoin Price… yeah… just that…
Go
4
star
10

herald

a harbinger of events or things.
Python
3
star
11

jsonc-cli

A CLI for jsonc - json with comments
Go
3
star
12

shiny-octo-doodle

Some scripts and snippets I use in building desktop and web apps.
C#
3
star
13

personal-website

A simple but amazing personal website template made from scratch.
HTML
3
star
14

RandomTheme

A simple php script to load random color codes for meta tag's attribute theme-color.
PHP
3
star
15

error_pages

HTTP error pages.
HTML
2
star
16

worst-js

The worst JavaScript you will ever see. Made with Love.
JavaScript
2
star
17

go-dist

Distribution script for programs written in Go
Shell
2
star
18

go-check

A simple error check for Go errors
Go
2
star
19

Libri

Library Management Software
Java
2
star
20

pagehash-go

Go library for Page Hash.
Go
2
star
21

CollegeStuff

Where(x =>x == typeof(Work.College))
Jupyter Notebook
2
star
22

unixtimestamp

Until 32-bit versions of the Unix time stamp will cease to work.
HTML
2
star
23

websitesby.muzzammil.xyz

Websites developed, renovated, designed and maintained by Muhammad Muzzammil
CSS
2
star
24

ohmy2zsh

ohmy2zsh is a bundle of zsh and ohmyzsh
Shell
1
star
25

BitcoinBot-Website

Website for BitcoinBot (https://github.com/muhammadmuzzammil1998/BitcoinBot)
HTML
1
star
26

Resume

My resume
TeX
1
star
27

JustAnAwesomeInc-Template

Simple - Clean - "Easy to setup" Website Template
PHP
1
star