Every line of 'golang json unmarshal' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.
41 func JSONUnmarshal(data []byte, v interface{}) error { 42 return json.Unmarshal(data, v) 43 }
91 func (et *EventType) UnmarshalJSON(data []byte) error { 92 switch string(data) { 93 case "\"added\"": 94 *et = EventAdded 95 case "\"removed\"": 96 *et = EventRemoved 97 default: 98 fmt.Println(string(data)) 99 return errors.New("bad event type") 100 } 101 102 return nil 103 }
633 func (pbi *ProcBindInfo) UnmarshalJSON(data []byte) error { 634 err := defaultProcBindInfoHandle.UJSON(data, pbi) 635 if err != nil { 636 return err 637 } 638 return nil 639 }
56 func (p *TxS) UnmarshalJSON(data []byte) (err error) { 57 parsed, err := txMapper.FromJSON(data) 58 if err == nil { 59 p.Tx = parsed.(Tx) 60 } 61 return 62 }
40 func UnmarshalFromJSON(data []byte) (*JsonRows, error) { 41 var jRows JsonRows 42 err := json.Unmarshal(data, &jRows) 43 44 if err != nil { 45 return nil, err 46 } 47 48 return &jRows, nil 49 }
48 func (b *Conditional) UnmarshalJSON(jsonData []byte) error { 49 jsonString := string(jsonData) 50 jsonBool, err := strconv.ParseBool(jsonString) 51 if err != nil && jsonString != "null" { 52 return err 53 } 54 55 if jsonString == "" || jsonString == "null" { 56 *b = DefaultEnabled 57 } else if jsonBool { 58 *b = ExplicitlyEnabled 59 } else { 60 *b = ExplicitlyDisabled 61 } 62 63 return nil 64 }
1232 func (i *ComponentsSecuritySchemesAZAZ09) UnmarshalJSON(data []byte) error { 1233 mayUnmarshal := []interface{}{&i.Reference, &i.SecurityScheme} 1234 err := unionMap{ 1235 mayUnmarshal: mayUnmarshal, 1236 jsonData: data, 1237 }.unmarshal() 1238 if mayUnmarshal[0] == nil { 1239 i.Reference = nil 1240 } 1241 if mayUnmarshal[1] == nil { 1242 i.SecurityScheme = nil 1243 } 1244 1245 return err 1246 }
25 func (m *SiteSetup) UnmarshalJSON(raw []byte) error { 26 // AO0 27 var aO0 Site 28 if err := swag.ReadJSON(raw, &aO0); err != nil { 29 return err 30 } 31 m.Site = aO0 32 33 // AO1 34 var dataAO1 struct { 35 Repo *RepoInfo `json:"repo,omitempty"` 36 } 37 if err := swag.ReadJSON(raw, &dataAO1); err != nil { 38 return err 39 } 40 41 m.Repo = dataAO1.Repo 42 43 return nil 44 }
26 func (m *V1PlatformPagedListPlatformsItemsCPUArchitectureAllOf1AllOf1) UnmarshalJSON(raw []byte) error { 27 // AO0 28 var aO0 V1PlatformPagedListPlatformsItemsCPUArchitectureAllOf1AllOf1AllOf0 29 if err := swag.ReadJSON(raw, &aO0); err != nil { 30 return err 31 } 32 m.V1PlatformPagedListPlatformsItemsCPUArchitectureAllOf1AllOf1AllOf0 = aO0 33 34 // AO1 35 var aO1 V1PlatformPagedListPlatformsItemsCPUArchitectureAllOf1AllOf1AllOf1 36 if err := swag.ReadJSON(raw, &aO1); err != nil { 37 return err 38 } 39 m.V1PlatformPagedListPlatformsItemsCPUArchitectureAllOf1AllOf1AllOf1 = aO1 40 41 return nil 42 }
21 func (m *PVMInstanceAddress) UnmarshalJSON(raw []byte) error { 22 // AO0 23 var aO0 PVMInstanceNetwork 24 if err := swag.ReadJSON(raw, &aO0); err != nil { 25 return err 26 } 27 m.PVMInstanceNetwork = aO0 28 29 return nil 30 }