Re: [go-nuts] json objects

2021-01-01 Thread Roland Müller
To have a JSon format with lower-case field names one has to (1) use field names beginning with upper case - to enable export and (2) use json annotations to force a field name. Just have a look at the following example: https://gobyexample.com/json Am Sa., 26. Dez

Re: [go-nuts] json objects

2020-12-26 Thread Martin Schnabel
hi hamsa, first of all: it is usually frowned upon to send text as pictures. so please copy text as text in the future. the are people with terminal mail clients or visually impaired using screen readers. the data in your example is neither valid json value nor a valid json stream. either you

Re: [go-nuts] json objects

2020-12-26 Thread Charles Radke
I think you probably to unmarshal into a []book. From: on behalf of Hamsa Hesham Date: Saturday, December 26, 2020 at 10:06 AM To: golang-nuts Subject: [go-nuts] json objects how to unmarshal more than one json object .. Here is the code data, err := ioutil.ReadFile("fil

[go-nuts] json objects

2020-12-26 Thread Hamsa Hesham
how to unmarshal more than one json object .. Here is the code data, err := ioutil.ReadFile("file.txt") checkError(err) x:=string(data) fmt.Println(x) var b1 book err1:=json.Unmarshal(data,&b1) fmt.Printf("Books : %+v", b1) checkError(err1) if b1.ID==ID

Re: [go-nuts] json objects

2020-12-25 Thread Charles Radke
Try to export your struct fields. Sent from my iPhone On Dec 25, 2020, at 6:30 PM, Amit Saha wrote:  On Sat, 26 Dec 2020, 10:25 am Hamsa Hesham, mailto:hamsahesha...@gmail.com>> wrote: package main import "encoding/json" import "log" import "fmt" type book struct { IDint ti

Re: [go-nuts] json objects

2020-12-25 Thread Amit Saha
On Sat, 26 Dec 2020, 10:25 am Hamsa Hesham, wrote: > package main > import "encoding/json" > import "log" > import "fmt" > > type book struct { > IDint > title string > pubDate string > authorstring > genre string > publisher string > language st

[go-nuts] json objects

2020-12-25 Thread Hamsa Hesham
package main import "encoding/json" import "log" import "fmt" type book struct { IDint title string pubDate string authorstring genre string publisher string language string } func main(){ b := book{ ID:1, title: "Standard", pubD