{"color":"red", "mrkdwn_in":["text"]}
to a structure in UnMarshal"mrkdwn_in":["text"]
does not maintain well
"mrkdwn_in": [{"text":"}]
or "mrkdwn_in":"
."mrkdwn_in": [{"text":"}]
or "mrkdwn_in":"
.package main
import(
"encoding/json"
"fmt"
)
type TestStructure {
Color string `json:`color``
MrkdwnIn[]MrkdwnIn`json: "mrkdwn_in"`
}
typeMrkdwnInstructure{
Text string `json:`text``
}
funcmain(){
jsonData1:="{\"color\":\"red\"',\"mrkdwn_in\":[\"text\"]}"
varbody TestStruct
json.Unmarshal([]byte(jsonData1), & body)
body.Color="blue"
varjsonData2[]byte
jsonData2,_=json.Marshal(body)
jsonDataText: =string(jsonData2)
fmt.Println(jsonDataText)
}
Now it's resolved.
MrkdwnIn[]MrkdwnIn`json: "mrkdwn_in"`
↓
MrkdwnIn[]string `json: "mrkdwn_in"`
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.