草庐IT

json-string

全部标签

sql - 如何返回嵌套的 JSON?

我在PostgreSQL数据库中有3个表。问题表:|id(int)|text(text)||----------|--------------------------------------||1|Whatisyourfavoritecolor?||2|Whatisyourfavoritefootballclub?|OPTIONS表:|id(int)|text(text)||----------|-------------||1|red||2|blue||3|grey||4|green||5|brown|QUESTIONS_OPTIONS表:|question_id(int)|opti

go - 如何将一段结构编码为有效的 JSON

我正在编写Golangapi和客户端,但无法从api中的结构片段中获取有效的json。我在客户端中得到的结果如下所示。[{0Mark1234false}{0John3456false}]我需要这个json看起来像[{"id":0,"name":Mark,"pin":1234,"active":false}{"id":0,"name":John,"pin":3456,"active":false}]我找不到向我展示如何正确编码的示例,尽管有警告,这不是我能找到的任何内容的重复。虽然我的客户端成功地将JSON解析回结构,但我还需要它将JSON返回给请求它的IOS客户端。流程是API->AP

json - API 请求和响应

我想知道HTTP客户端是否可以在Go中使用不同的JSON对象发布特定的JSON对象和服务器响应。例如,客户端发送JSON对象请求正文{"nfNssaiAvailabilityUri":"string","taiList":[{"plmnId":{"mcc":"string","mnc":"string"},"tac":"string"}],"expiry":"2019-04-01T10:41:54.344Z"}响应主体为{"subscriptionId":"string","expiry":"2019-04-01T10:41:54.363Z","authorizedNssaiAvail

json - Golang 运行时 : goroutine stack exceeds 1000000000-byte limit

当我尝试Marshall嵌套结构的对象时出现此错误。我的结构看起来像:typeBlockchainstruct{blocks[]Block`json:"blocks"`difficultyint`json:"difficulty"`}typeBlockstruct{indexint`json:"index"`timestampstring`json:"timestamp"`datastring`json:"data"`previousHashstring`json:"previousHash"`hashstring`json:"hash"`nonceint`json:"nonce"`}

Go Lang 中的 JSON 结构到 csv

寻找在保留层次结构的同时将JSON读取结构导出为某种csv格式的想法。https://play.golang.org/p/jf2DRL1hC5K/*Expectedoutputinexcelfordatawrangling:AKey|BKey|CKey|DKeySomethingASomethingBSomethingCSomethingFSomethingASomethingBSomethingCSomethingGSomethingASomethingBSomethingC[1,2,3]*/我试过如下遍历结构for_,value:=rangemymodel{fmt.Println(

string - 严格将字符串转换为 int

关闭。这个问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭3年前。Improvethisquestion我正在尝试存储一个十六进制字符串值:ex"3958ABBFEC23BD40"到uint64,就像这样:fmt.Println(myuint64)$0x3958ABBFEC23BD40我尝试过使用编码/十六进制,或将strconv转换为int等...我找不

json - 尝试解析 JSON 并创建提取的 JSON

我正在尝试根据从API接收到的数据动态创建一个JSON对象。收到的示例数据:将数据解码到下面给出的CiItems结构中{"class_name":"test","configuration_items":[{"id":"ea09a24f-01ef-42ad-ab19-e0369341d9b3","ci_name":"makk","comments":null,"created_by":"mike","updated_by":"sam","created":"2019-08-02T21:16:35.656Z","updated":"2019-08-02T21:21:08.073Z","c

go - 不能使用 args (type []string) 作为 type []interface {}

这个问题在这里已经有了答案:Typeconvertingslicesofinterfaces(9个回答)关闭3年前。我的golangsqlite插入函数。我正在使用这个包"github.com/mattn/go-sqlite3"funcInsert(args...string)(errerror){db,err:=sql.Open("sqlite3","sqlite.db")iferr!=nil{return}q,err:=db.Prepare(args[0])iferr!=nil{return}_,err=q.Exec(args[1:]...)return}main(){err:=I

mongodb - 使用 golang 从 mongo 获取一段 json 字符串

我正在尝试使用golang中的以下代码从mongo获取一段json文本vara[]stringerr:=col..Find(nil).Select(bson.M{"_id":0}).All(&a)我得到错误Unsupporteddocumenttypeforunmarshalling:string我可以知道这样做的正确方法吗? 最佳答案 当您选择除_id之外的所有内容时,返回的将是一个仅包含剩余字段的文档。你可以这样做:typefieldDocstruct{Fieldstring`bson:"name"`}vara[]fieldDo

go - 有没有办法根据内容动态解码 json?

这个问题在这里已经有了答案:HowtoparseJSONingolangwithoutunmarshalingtwice(3个答案)HowtoparseacomplicatedJSONwithGounmarshal?(3个答案)DecodinggenericJSONobjectstooneofmanyformats(1个回答)HowtopartiallyparseJSONusingGo?(3个答案)关闭3年前。我有一个像这样的json格式{"my_object_list":[{"meta":{"version":1},"my_value":{//Somecomplexvalue}}{"