FAQ
Hello.

I am writing a Google AppEngine app in Go. It has a web service that goes
to the Datastore and spits out JSON.

Now. What I want is to have the entities represented in JSON to contain the
entity key value.

Here's some pseudo-code of what I'm doing.
----------------------------------------------------------------
type Hum struct {
UID string
}

hums := make([]Hum, 0, 10)
if _, err := q.GetAll(c, &hums); err != nil {
fmt.Printf("error")
}
b, err := json.Marshal(hums);
if err != nil {
fmt.Printf("error")
}
w.Write([]byte(r.FormValue("jsoncallback")))
w.Write([]byte("("))
w.Write(b)
w.Write([]byte(")"))
----------------------------------------------------------------

So if I want the entity Datastore Key ID for each Hum entity - that is
where I'm lost.

Guessing I may have to put a Key property in the Hum struct maybe?

Any suggestions appreciated.

--

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 17, '12 at 4:34a
activeDec 17, '12 at 5:02a
posts2
users1
websitegolang.org

1 user in discussion

Daniel Combs: 2 posts

People

Translate

site design / logo © 2022 Grokbase