Начал писать
This commit is contained in:
parent
4577a92c6a
commit
f98a497c40
1 changed files with 35 additions and 0 deletions
35
main.go
Normal file
35
main.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type JsonInterface interface{}
|
||||
|
||||
func getJson(url string) string {
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
return string(body)
|
||||
}
|
||||
|
||||
func unmJson(jsonString string) JsonInterface {
|
||||
var decodedJson JsonInterface
|
||||
err := json.Unmarshal([]byte(jsonString), &decodedJson)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
return decodedJson
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(unmJson(getJson("https://pleroma.catgirls.asia/api/v1/instance")))
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue