LoginSignup
1
2

More than 5 years have passed since last update.

【go】json.Numberからintに変換する

Posted at

一応以下でできました

main.go
package main

import (
    "encoding/json"
    "fmt"
)

func myfunc(num json.Number) {
    id, _ := num.Int64()
    fmt.Print(int(id))
}

int64に変換できるのがポイントです。
数値型にも色々あってちゃんと理解してないとはまりますね。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2