github.com/sandwich-go/boost@v1.3.29/xstrings/json_test.go (about)

     1  package xstrings
     2  
     3  import (
     4  	. "github.com/smartystreets/goconvey/convey"
     5  	"testing"
     6  )
     7  
     8  func TestJson(t *testing.T) {
     9  	Convey("json", t, func() {
    10  		s := `{a: 1}`
    11  		So(ValidJSON([]byte(s)), ShouldBeFalse)
    12  
    13  		s = `{"a": 1}`
    14  		So(ValidJSON([]byte(s)), ShouldBeTrue)
    15  
    16  		s = `
    17  {
    18  	"a": 1,
    19  	"b": 2
    20  }
    21  `
    22  		So(string(UglyJSON([]byte(s))), ShouldEqual, `{"a":1,"b":2}`)
    23  	})
    24  }