1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Update github.com/DisposaBoy/JsonConfigReader (#514)

This commit is contained in:
Tom Limoncelli
2019-06-30 09:05:38 -04:00
committed by GitHub
parent d5ff6d6e5c
commit ffc0a10c64
4 changed files with 37 additions and 3 deletions

View File

@ -2,3 +2,4 @@ This is the official list of JsonConfigReader authors for copyright purposes.
* DisposaBoy `https://github.com/DisposaBoy`
* Steven Osborn `https://github.com/steve918`
* Andreas Jaekle `https://github.com/ekle`

View File

@ -1,6 +1,14 @@
[![Build Status](https://travis-ci.org/DisposaBoy/JsonConfigReader.svg?branch=master)](https://travis-ci.org/DisposaBoy/JsonConfigReader)
<hr/>
JsonConfigReader is a proxy for [golang's io.Reader](http://golang.org/pkg/io/#Reader) that strips line comments and trailing commas, allowing you to use json as a *reasonable* config format.
Comments start with `//` and continue to the end of the line.
Multiline comments are also supported with `/*` and `*/`.
If a trailing comma is in front of `]` or `}` it will be stripped as well.
@ -9,9 +17,15 @@ Given `settings.json`
{
"key": "value", // k:v
// a list of numbers
"list": [1, 2, 3],
/*
a list of numbers
which are important
*/
"numbers": [1, 2, 3],
}

View File

@ -25,6 +25,24 @@ func consumeComment(s []byte, i int) int {
s[i] = ' '
}
}
if i < len(s) && s[i] == '*' {
s[i-1] = ' '
s[i] = ' '
for ; i < len(s); i += 1 {
if s[i] != '*' {
s[i] = ' '
} else {
s[i] = ' '
i++
if i < len(s) {
if s[i] == '/' {
s[i] = ' '
break
}
}
}
}
}
return i
}

5
vendor/vendor.json vendored
View File

@ -15,9 +15,10 @@
"revisionTime": "2016-09-16T22:17:49Z"
},
{
"checksumSHA1": "3GJ+FRKP1nniJMokdcb/ZEcq3tE=",
"path": "github.com/DisposaBoy/JsonConfigReader",
"revision": "33a99fdf1d5ee1f79b5077e9c06f955ad356d5f4",
"revisionTime": "2013-01-12T09:33:55Z"
"revision": "5ea4d0ddac554439159cd6f191cb94a110d73352",
"revisionTime": "2017-12-18T18:09:44Z"
},
{
"checksumSHA1": "E0NbOzBCBYViPKvM4XcloBu6GWE=",