cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Unable to unmarshal json data from relationship query in golang

Hello!

I'm trying to unmarshal the result (res) but it's throwing me an error. Anyone know a way to do this properly?

res, err := tx.Run("MATCH result=(p:Products) <-[r1:PRODUCES]- (i:Inventory) -[r2:OWNED_BY]->()  return result",
	   map[string]interface{}{"skip": skip, "limit": limit})
		         if err != nil {
			         return nil, err
		         }

	   for res.Next() {
			m := make(map[string]interface{})
			d := res.Record().GetByIndex(0)
			err := json.Unmarshal([]byte(fmt.Sprintf("%v", &d)), &m)
			fmt.Println(m, err)
        }

Error :
map[] invalid character 'x' after top-level value

Thanks!

2 REPLIES 2

I'm still stuck with this. Could I get some help?

I came across this but just not sure if it's recommended for neo4j ?

import (
    _ "github.com/wfreeman/cq"
    "database/sql"
    "github.com/jmoiron/sqlx"
    "log"
)

type Person struct {
    Name string `db:"first_name"`
    Email     string
}

func main() {
    db, err := sqlx.Connect("neo4j-cypher", "http://localhost:7474")
    if err != nil {
        log.Fatalln(err)
    }

    people := []Person{}
    db.Select(&people, "MATCH (n:Person) RETURN n.name AS first_name, n.email AS email")
}

clem
Graph Steward

I don't know GoLang (or what unmarshal means), but the error message doesn't make sense to me. What "x" is the err msg referring to?

I only see the letter x in tx and Next

Sorry....