Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
c95c27a9
Commit
c95c27a9
authored
Nov 23, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
json: expose map in generic representation
R=r, r1
https://golang.org/cl/157146
parent
8ebd7f71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
+7
-0
src/pkg/json/generic.go
src/pkg/json/generic.go
+3
-0
src/pkg/json/generic_test.go
src/pkg/json/generic_test.go
+4
-0
No files found.
src/pkg/json/generic.go
View file @
c95c27a9
...
...
@@ -33,6 +33,7 @@ type Json interface {
Get
(
s
string
)
Json
;
// field lookup (MapKind)
Elem
(
i
int
)
Json
;
// element lookup (ArrayKind)
Len
()
int
;
// length (ArrayKind, MapKind)
Map
()
map
[
string
]
Json
;
// map form (MapKind)
}
// JsonToString returns the textual JSON syntax representation
...
...
@@ -63,6 +64,7 @@ func (*_Null) Bool() bool { return false }
func
(
*
_Null
)
Get
(
s
string
)
Json
{
return
Null
}
func
(
*
_Null
)
Elem
(
int
)
Json
{
return
Null
}
func
(
*
_Null
)
Len
()
int
{
return
0
}
func
(
*
_Null
)
Map
()
map
[
string
]
Json
{
return
nil
}
type
_String
struct
{
s
string
;
...
...
@@ -158,6 +160,7 @@ func (j *_Map) String() string {
s
+=
"}"
;
return
s
;
}
func
(
j
*
_Map
)
Map
()
map
[
string
]
Json
{
return
j
.
m
}
// Walk evaluates path relative to the JSON object j.
// Path is taken as a sequence of slash-separated field names
...
...
src/pkg/json/generic_test.go
View file @
c95c27a9
...
...
@@ -5,6 +5,7 @@
package
json
import
(
"reflect"
;
"testing"
;
)
...
...
@@ -73,4 +74,7 @@ func TestJsonMap(t *testing.T) {
t
.
Errorf
(
"MapTest: Walk(%#q) => %v, want %v"
,
k
,
v1
,
v
)
}
}
if
!
reflect
.
DeepEqual
(
values
,
mapv
.
Map
())
{
t
.
Errorf
(
"DeepEqual(values, mapv.Map()) failed"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment