diff options
| author | Sergey 'SnakE' Gromov <snake.scaly@gmail.com> | 2009-11-30 13:55:09 -0800 |
|---|---|---|
| committer | Sergey 'SnakE' Gromov <snake.scaly@gmail.com> | 2009-11-30 13:55:09 -0800 |
| commit | 7ea3f61ab343b1115d561dd051879fccbb35df20 (patch) | |
| tree | 61f69f892695ac35bc78ad8c4f60739836ddc0b9 /src/pkg/json/error.go | |
| parent | 2b64b6a9acdf85fca4a457d4364fa468d0ad2ffe (diff) | |
| download | golang-7ea3f61ab343b1115d561dd051879fccbb35df20.tar.gz | |
json: Decode into native Go data structures
This patch adds an ability to convert JSON-encoded data into
a hierarchy of Go's native data types.
R=rsc
CC=golang-dev
http://codereview.appspot.com/161060
Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/json/error.go')
| -rw-r--r-- | src/pkg/json/error.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/pkg/json/error.go b/src/pkg/json/error.go new file mode 100644 index 000000000..aa5b962ae --- /dev/null +++ b/src/pkg/json/error.go @@ -0,0 +1,19 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package json + +import "fmt" + +// ParseError aggregates information about a JSON parse error. It is +// compatible with the os.Error interface. +type ParseError struct { + Index int; // A byte index in JSON string where the error occurred + Token string; // An offending token +} + +// Produce a string representation of this ParseError. +func (pe *ParseError) String() string { + return fmt.Sprintf("Unexpected JSON token at position %d: %q.", pe.Index, pe.Token) +} |
