We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
`package main
import ( "encoding/json" "github.com/json-iterator/go" "strings" "fmt" )
const jsonStream = {"name":"xxxxx","bundle_id":"com.zonst.majiang","app_platform":"ios","app_category":"100103", "budget_day":1000,"bidding_min":1,"bidding_max":2,"bidding_type":"CPM", "freq":{"open":true,"type":"day","num":100},"speed":1, "targeting":{"vendor":{"open":true,"list":["zonst"]}, "geo_code":{"open":true,"list":["156110100"]},"app_category":{"open":true,"list":["100101"]}, "day_parting":{"open":true,"list":["100409","100410"]},"device_type":{"open":true,"list":["ipad"]}, "os_version":{"open":true,"list":[10]},"carrier":{"open":true,"list":["mobile"]}, "network":{"open":true,"list":["4G"]}},"url":{"tracking_imp_url":"http://www.baidu.com", "tracking_clk_url":"http://www.baidu.com","jump_url":"http://www.baidu.com","deep_link_url":"http://www.baidu.com"}}
{"name":"xxxxx","bundle_id":"com.zonst.majiang","app_platform":"ios","app_category":"100103", "budget_day":1000,"bidding_min":1,"bidding_max":2,"bidding_type":"CPM", "freq":{"open":true,"type":"day","num":100},"speed":1, "targeting":{"vendor":{"open":true,"list":["zonst"]}, "geo_code":{"open":true,"list":["156110100"]},"app_category":{"open":true,"list":["100101"]}, "day_parting":{"open":true,"list":["100409","100410"]},"device_type":{"open":true,"list":["ipad"]}, "os_version":{"open":true,"list":[10]},"carrier":{"open":true,"list":["mobile"]}, "network":{"open":true,"list":["4G"]}},"url":{"tracking_imp_url":"http://www.baidu.com", "tracking_clk_url":"http://www.baidu.com","jump_url":"http://www.baidu.com","deep_link_url":"http://www.baidu.com"}}
func IteratorReadJsonObject(obj interface{}) error { decoder := jsoniter.NewDecoder(strings.NewReader(jsonStream)) err := decoder.Decode(obj) if err != nil { return err } return nil } func ReadJsonObject(obj interface{}) error { decoder := json.NewDecoder(strings.NewReader(jsonStream)) err := decoder.Decode(obj) if err != nil { return err } return nil }
type IteratorObject struct { Name *string json:"name" BundleId *string json:"bundle_id" AppCategory *string json:"app_category" AppPlatform *string json:"app_platform" BudgetDay *float32 json:"budget_day" BiddingMax *float32 json:"bidding_max" BiddingMin *float32 json:"bidding_min" BiddingType *string json:"bidding_type" Freq *jsoniter.RawMessage json:"freq" Targeting *jsoniter.RawMessage json:"targeting" Url *jsoniter.RawMessage json:"url" Speed *int json:"speed" db:"speed" } type Object struct { Name *string json:"name" BundleId *string json:"bundle_id" AppCategory *string json:"app_category" AppPlatform *string json:"app_platform" BudgetDay *float32 json:"budget_day" BiddingMax *float32 json:"bidding_max" BiddingMin *float32 json:"bidding_min" BiddingType *string json:"bidding_type" Freq *json.RawMessage json:"freq" Targeting *json.RawMessage json:"targeting" Url *json.RawMessage json:"url" Speed *int json:"speed" db:"speed" }
json:"name"
json:"bundle_id"
json:"app_category"
json:"app_platform"
json:"budget_day"
json:"bidding_max"
json:"bidding_min"
json:"bidding_type"
json:"freq"
json:"targeting"
json:"url"
json:"speed" db:"speed"
func main() { iterator_obj, obj := &IteratorObject{}, &Object{} IteratorReadJsonObject(iterator_obj) ReadJsonObject(obj) fmt.Println("iterator:" + string(*iterator_obj.Freq)) //ttp://www.baidu.com","jump_url":"htt fmt.Println("default:" + string(*obj.Freq)) //{"open":true,"type":"day","num":100}
}`
The text was updated successfully, but these errors were encountered:
#178 SkipAndReturnBytes should return copy of memory
46b20bb
should be fixed now
Sorry, something went wrong.
json-iterator#178 SkipAndReturnBytes should return copy of memory
258fed4
No branches or pull requests
`package main
import (
"encoding/json"
"github.com/json-iterator/go"
"strings"
"fmt"
)
const jsonStream =
{"name":"xxxxx","bundle_id":"com.zonst.majiang","app_platform":"ios","app_category":"100103", "budget_day":1000,"bidding_min":1,"bidding_max":2,"bidding_type":"CPM", "freq":{"open":true,"type":"day","num":100},"speed":1, "targeting":{"vendor":{"open":true,"list":["zonst"]}, "geo_code":{"open":true,"list":["156110100"]},"app_category":{"open":true,"list":["100101"]}, "day_parting":{"open":true,"list":["100409","100410"]},"device_type":{"open":true,"list":["ipad"]}, "os_version":{"open":true,"list":[10]},"carrier":{"open":true,"list":["mobile"]}, "network":{"open":true,"list":["4G"]}},"url":{"tracking_imp_url":"http://www.baidu.com", "tracking_clk_url":"http://www.baidu.com","jump_url":"http://www.baidu.com","deep_link_url":"http://www.baidu.com"}}
func IteratorReadJsonObject(obj interface{}) error {
decoder := jsoniter.NewDecoder(strings.NewReader(jsonStream))
err := decoder.Decode(obj)
if err != nil {
return err
}
return nil
}
func ReadJsonObject(obj interface{}) error {
decoder := json.NewDecoder(strings.NewReader(jsonStream))
err := decoder.Decode(obj)
if err != nil {
return err
}
return nil
}
type IteratorObject struct {
Name *string
json:"name"
BundleId *string
json:"bundle_id"
AppCategory *string
json:"app_category"
AppPlatform *string
json:"app_platform"
BudgetDay *float32
json:"budget_day"
BiddingMax *float32
json:"bidding_max"
BiddingMin *float32
json:"bidding_min"
BiddingType *string
json:"bidding_type"
Freq *jsoniter.RawMessage
json:"freq"
Targeting *jsoniter.RawMessage
json:"targeting"
Url *jsoniter.RawMessage
json:"url"
Speed *int
json:"speed" db:"speed"
}
type Object struct {
Name *string
json:"name"
BundleId *string
json:"bundle_id"
AppCategory *string
json:"app_category"
AppPlatform *string
json:"app_platform"
BudgetDay *float32
json:"budget_day"
BiddingMax *float32
json:"bidding_max"
BiddingMin *float32
json:"bidding_min"
BiddingType *string
json:"bidding_type"
Freq *json.RawMessage
json:"freq"
Targeting *json.RawMessage
json:"targeting"
Url *json.RawMessage
json:"url"
Speed *int
json:"speed" db:"speed"
}
func main() {
iterator_obj, obj := &IteratorObject{}, &Object{}
IteratorReadJsonObject(iterator_obj)
ReadJsonObject(obj)
fmt.Println("iterator:" + string(*iterator_obj.Freq)) //ttp://www.baidu.com","jump_url":"htt
fmt.Println("default:" + string(*obj.Freq)) //{"open":true,"type":"day","num":100}
}`
The text was updated successfully, but these errors were encountered: