Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/json: export func Valid(byte) bool #18086
I'm running go version go1.7.1 darwin/amd64 on macOS 10.12.1.
I'm trying to validate some a byte array is valid JSON so it can be marshalled literally like RawMessage. The only way to do this at the moment is to create a Decoder and fully decode the bytes causing many useless allocations, or write a custom scanner.
But there's a lovely, allocation-free function for scanning a byte array to see if it's valid JSON tucked away inside the encoding/json package (checkValid), and used in several places within the package. It'd be great to expose this for general use as something like