Best K6 code snippet using metrics.MarshalEasyJSON
metrics.pb_easyjson.go
Source:metrics.pb_easyjson.go
...104 w := jwriter.Writer{}105 easyjson16bbae25EncodeCadentServerSchemasMetrics(&w, v)106 return w.Buffer.BuildBytes(), w.Error107}108// MarshalEasyJSON supports easyjson.Marshaler interface109func (v GraphiteApiItemList) MarshalEasyJSON(w *jwriter.Writer) {110 easyjson16bbae25EncodeCadentServerSchemasMetrics(w, v)111}112// UnmarshalJSON supports json.Unmarshaler interface113func (v *GraphiteApiItemList) UnmarshalJSON(data []byte) error {114 r := jlexer.Lexer{Data: data}115 easyjson16bbae25DecodeCadentServerSchemasMetrics(&r, v)116 return r.Error()117}118// UnmarshalEasyJSON supports easyjson.Unmarshaler interface119func (v *GraphiteApiItemList) UnmarshalEasyJSON(l *jlexer.Lexer) {120 easyjson16bbae25DecodeCadentServerSchemasMetrics(l, v)121}122func easyjson16bbae25DecodeCadentServerSchemasMetrics1(in *jlexer.Lexer, out *GraphiteApiItem) {123 isTopLevel := in.IsStart()124 if in.IsNull() {125 if isTopLevel {126 in.Consumed()127 }128 in.Skip()129 return130 }131 in.Delim('{')132 for !in.IsDelim('}') {133 key := in.UnsafeString()134 in.WantColon()135 if in.IsNull() {136 in.Skip()137 in.WantComma()138 continue139 }140 switch key {141 case "target":142 out.Target = string(in.String())143 case "in_cache":144 out.InCache = bool(in.Bool())145 case "using_cache":146 out.UsingCache = bool(in.Bool())147 case "datapoints":148 if in.IsNull() {149 in.Skip()150 out.Datapoints = nil151 } else {152 in.Delim('[')153 if !in.IsDelim(']') {154 out.Datapoints = make([]*DataPoint, 0, 8)155 } else {156 out.Datapoints = []*DataPoint{}157 }158 for !in.IsDelim(']') {159 var v4 *DataPoint160 if in.IsNull() {161 in.Skip()162 v4 = nil163 } else {164 if v4 == nil {165 v4 = new(DataPoint)166 }167 easyjson16bbae25DecodeCadentServerSchemasMetrics2(in, &*v4)168 }169 out.Datapoints = append(out.Datapoints, v4)170 in.WantComma()171 }172 in.Delim(']')173 }174 default:175 in.SkipRecursive()176 }177 in.WantComma()178 }179 in.Delim('}')180 if isTopLevel {181 in.Consumed()182 }183}184func easyjson16bbae25EncodeCadentServerSchemasMetrics1(out *jwriter.Writer, in GraphiteApiItem) {185 out.RawByte('{')186 first := true187 _ = first188 if in.Target != "" {189 if !first {190 out.RawByte(',')191 }192 first = false193 out.RawString("\"target\":")194 out.String(string(in.Target))195 }196 if in.InCache {197 if !first {198 out.RawByte(',')199 }200 first = false201 out.RawString("\"in_cache\":")202 out.Bool(bool(in.InCache))203 }204 if in.UsingCache {205 if !first {206 out.RawByte(',')207 }208 first = false209 out.RawString("\"using_cache\":")210 out.Bool(bool(in.UsingCache))211 }212 if len(in.Datapoints) != 0 {213 if !first {214 out.RawByte(',')215 }216 first = false217 out.RawString("\"datapoints\":")218 if in.Datapoints == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {219 out.RawString("null")220 } else {221 out.RawByte('[')222 for v5, v6 := range in.Datapoints {223 if v5 > 0 {224 out.RawByte(',')225 }226 if v6 == nil {227 out.RawString("null")228 } else {229 out.Raw((*v6).MarshalJSON())230 }231 }232 out.RawByte(']')233 }234 }235 out.RawByte('}')236}237// MarshalJSON supports json.Marshaler interface238func (v GraphiteApiItem) MarshalJSON() ([]byte, error) {239 w := jwriter.Writer{}240 easyjson16bbae25EncodeCadentServerSchemasMetrics1(&w, v)241 return w.Buffer.BuildBytes(), w.Error242}243// MarshalEasyJSON supports easyjson.Marshaler interface244func (v GraphiteApiItem) MarshalEasyJSON(w *jwriter.Writer) {245 easyjson16bbae25EncodeCadentServerSchemasMetrics1(w, v)246}247// UnmarshalJSON supports json.Unmarshaler interface248func (v *GraphiteApiItem) UnmarshalJSON(data []byte) error {249 r := jlexer.Lexer{Data: data}250 easyjson16bbae25DecodeCadentServerSchemasMetrics1(&r, v)251 return r.Error()252}253// UnmarshalEasyJSON supports easyjson.Unmarshaler interface254func (v *GraphiteApiItem) UnmarshalEasyJSON(l *jlexer.Lexer) {255 easyjson16bbae25DecodeCadentServerSchemasMetrics1(l, v)256}257func easyjson16bbae25DecodeCadentServerSchemasMetrics2(in *jlexer.Lexer, out *DataPoint) {258 isTopLevel := in.IsStart()259 if in.IsNull() {260 if isTopLevel {261 in.Consumed()262 }263 in.Skip()264 return265 }266 in.Delim('{')267 for !in.IsDelim('}') {268 key := in.UnsafeString()269 in.WantColon()270 if in.IsNull() {271 in.Skip()272 in.WantComma()273 continue274 }275 switch key {276 case "time":277 out.Time = uint32(in.Uint32())278 case "value":279 out.Value = float64(in.Float64())280 default:281 in.SkipRecursive()282 }283 in.WantComma()284 }285 in.Delim('}')286 if isTopLevel {287 in.Consumed()288 }289}290func easyjson16bbae25EncodeCadentServerSchemasMetrics2(out *jwriter.Writer, in DataPoint) {291 out.RawByte('{')292 first := true293 _ = first294 if in.Time != 0 {295 if !first {296 out.RawByte(',')297 }298 first = false299 out.RawString("\"time\":")300 out.Uint32(uint32(in.Time))301 }302 if in.Value != 0 {303 if !first {304 out.RawByte(',')305 }306 first = false307 out.RawString("\"value\":")308 out.Float64(float64(in.Value))309 }310 out.RawByte('}')311}312func easyjson16bbae25DecodeCadentServerSchemasMetrics3(in *jlexer.Lexer, out *WhisperDataItemList) {313 isTopLevel := in.IsStart()314 if in.IsNull() {315 if isTopLevel {316 in.Consumed()317 }318 in.Skip()319 return320 }321 in.Delim('{')322 for !in.IsDelim('}') {323 key := in.UnsafeString()324 in.WantColon()325 if in.IsNull() {326 in.Skip()327 in.WantComma()328 continue329 }330 switch key {331 case "items":332 if in.IsNull() {333 in.Skip()334 out.Items = nil335 } else {336 in.Delim('[')337 if !in.IsDelim(']') {338 out.Items = make([]*WhisperDataItem, 0, 8)339 } else {340 out.Items = []*WhisperDataItem{}341 }342 for !in.IsDelim(']') {343 var v7 *WhisperDataItem344 if in.IsNull() {345 in.Skip()346 v7 = nil347 } else {348 if v7 == nil {349 v7 = new(WhisperDataItem)350 }351 if data := in.Raw(); in.Ok() {352 in.AddError((*v7).UnmarshalJSON(data))353 }354 }355 out.Items = append(out.Items, v7)356 in.WantComma()357 }358 in.Delim(']')359 }360 default:361 in.SkipRecursive()362 }363 in.WantComma()364 }365 in.Delim('}')366 if isTopLevel {367 in.Consumed()368 }369}370func easyjson16bbae25EncodeCadentServerSchemasMetrics3(out *jwriter.Writer, in WhisperDataItemList) {371 out.RawByte('{')372 first := true373 _ = first374 if len(in.Items) != 0 {375 if !first {376 out.RawByte(',')377 }378 first = false379 out.RawString("\"items\":")380 if in.Items == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {381 out.RawString("null")382 } else {383 out.RawByte('[')384 for v8, v9 := range in.Items {385 if v8 > 0 {386 out.RawByte(',')387 }388 if v9 == nil {389 out.RawString("null")390 } else {391 out.Raw((*v9).MarshalJSON())392 }393 }394 out.RawByte(']')395 }396 }397 out.RawByte('}')398}399// MarshalJSON supports json.Marshaler interface400func (v WhisperDataItemList) MarshalJSON() ([]byte, error) {401 w := jwriter.Writer{}402 easyjson16bbae25EncodeCadentServerSchemasMetrics3(&w, v)403 return w.Buffer.BuildBytes(), w.Error404}405// MarshalEasyJSON supports easyjson.Marshaler interface406func (v WhisperDataItemList) MarshalEasyJSON(w *jwriter.Writer) {407 easyjson16bbae25EncodeCadentServerSchemasMetrics3(w, v)408}409// UnmarshalJSON supports json.Unmarshaler interface410func (v *WhisperDataItemList) UnmarshalJSON(data []byte) error {411 r := jlexer.Lexer{Data: data}412 easyjson16bbae25DecodeCadentServerSchemasMetrics3(&r, v)413 return r.Error()414}415// UnmarshalEasyJSON supports easyjson.Unmarshaler interface416func (v *WhisperDataItemList) UnmarshalEasyJSON(l *jlexer.Lexer) {417 easyjson16bbae25DecodeCadentServerSchemasMetrics3(l, v)418}419func easyjson16bbae25DecodeCadentServerSchemasMetrics4(in *jlexer.Lexer, out *WhisperDataItem) {420 isTopLevel := in.IsStart()421 if in.IsNull() {422 if isTopLevel {423 in.Consumed()424 }425 in.Skip()426 return427 }428 in.Delim('{')429 for !in.IsDelim('}') {430 key := in.UnsafeString()431 in.WantColon()432 if in.IsNull() {433 in.Skip()434 in.WantComma()435 continue436 }437 switch key {438 case "target":439 out.Target = string(in.String())440 case "in_cache":441 out.InCache = bool(in.Bool())442 case "using_cache":443 out.UsingCache = bool(in.Bool())444 case "uid":445 out.Uid = string(in.String())446 case "data":447 if in.IsNull() {448 in.Skip()449 out.Data = nil450 } else {451 in.Delim('[')452 if !in.IsDelim(']') {453 out.Data = make([]*DataPoint, 0, 8)454 } else {455 out.Data = []*DataPoint{}456 }457 for !in.IsDelim(']') {458 var v10 *DataPoint459 if in.IsNull() {460 in.Skip()461 v10 = nil462 } else {463 if v10 == nil {464 v10 = new(DataPoint)465 }466 easyjson16bbae25DecodeCadentServerSchemasMetrics2(in, &*v10)467 }468 out.Data = append(out.Data, v10)469 in.WantComma()470 }471 in.Delim(']')472 }473 default:474 in.SkipRecursive()475 }476 in.WantComma()477 }478 in.Delim('}')479 if isTopLevel {480 in.Consumed()481 }482}483func easyjson16bbae25EncodeCadentServerSchemasMetrics4(out *jwriter.Writer, in WhisperDataItem) {484 out.RawByte('{')485 first := true486 _ = first487 if in.Target != "" {488 if !first {489 out.RawByte(',')490 }491 first = false492 out.RawString("\"target\":")493 out.String(string(in.Target))494 }495 if in.InCache {496 if !first {497 out.RawByte(',')498 }499 first = false500 out.RawString("\"in_cache\":")501 out.Bool(bool(in.InCache))502 }503 if in.UsingCache {504 if !first {505 out.RawByte(',')506 }507 first = false508 out.RawString("\"using_cache\":")509 out.Bool(bool(in.UsingCache))510 }511 if in.Uid != "" {512 if !first {513 out.RawByte(',')514 }515 first = false516 out.RawString("\"uid\":")517 out.String(string(in.Uid))518 }519 if len(in.Data) != 0 {520 if !first {521 out.RawByte(',')522 }523 first = false524 out.RawString("\"data\":")525 if in.Data == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {526 out.RawString("null")527 } else {528 out.RawByte('[')529 for v11, v12 := range in.Data {530 if v11 > 0 {531 out.RawByte(',')532 }533 if v12 == nil {534 out.RawString("null")535 } else {536 out.Raw((*v12).MarshalJSON())537 }538 }539 out.RawByte(']')540 }541 }542 out.RawByte('}')543}544// MarshalJSON supports json.Marshaler interface545func (v WhisperDataItem) MarshalJSON() ([]byte, error) {546 w := jwriter.Writer{}547 easyjson16bbae25EncodeCadentServerSchemasMetrics4(&w, v)548 return w.Buffer.BuildBytes(), w.Error549}550// MarshalEasyJSON supports easyjson.Marshaler interface551func (v WhisperDataItem) MarshalEasyJSON(w *jwriter.Writer) {552 easyjson16bbae25EncodeCadentServerSchemasMetrics4(w, v)553}554// UnmarshalJSON supports json.Unmarshaler interface555func (v *WhisperDataItem) UnmarshalJSON(data []byte) error {556 r := jlexer.Lexer{Data: data}557 easyjson16bbae25DecodeCadentServerSchemasMetrics4(&r, v)558 return r.Error()559}560// UnmarshalEasyJSON supports easyjson.Unmarshaler interface561func (v *WhisperDataItem) UnmarshalEasyJSON(l *jlexer.Lexer) {562 easyjson16bbae25DecodeCadentServerSchemasMetrics4(l, v)563}564func easyjson16bbae25DecodeCadentServerSchemasMetrics5(in *jlexer.Lexer, out *RawRenderItemList) {565 isTopLevel := in.IsStart()566 if in.IsNull() {567 if isTopLevel {568 in.Consumed()569 }570 in.Skip()571 return572 }573 in.Delim('{')574 for !in.IsDelim('}') {575 key := in.UnsafeString()576 in.WantColon()577 if in.IsNull() {578 in.Skip()579 in.WantComma()580 continue581 }582 switch key {583 case "items":584 if in.IsNull() {585 in.Skip()586 out.Items = nil587 } else {588 in.Delim('[')589 if !in.IsDelim(']') {590 out.Items = make([]*RawRenderItem, 0, 8)591 } else {592 out.Items = []*RawRenderItem{}593 }594 for !in.IsDelim(']') {595 var v13 *RawRenderItem596 if in.IsNull() {597 in.Skip()598 v13 = nil599 } else {600 if v13 == nil {601 v13 = new(RawRenderItem)602 }603 if data := in.Raw(); in.Ok() {604 in.AddError((*v13).UnmarshalJSON(data))605 }606 }607 out.Items = append(out.Items, v13)608 in.WantComma()609 }610 in.Delim(']')611 }612 default:613 in.SkipRecursive()614 }615 in.WantComma()616 }617 in.Delim('}')618 if isTopLevel {619 in.Consumed()620 }621}622func easyjson16bbae25EncodeCadentServerSchemasMetrics5(out *jwriter.Writer, in RawRenderItemList) {623 out.RawByte('{')624 first := true625 _ = first626 if len(in.Items) != 0 {627 if !first {628 out.RawByte(',')629 }630 first = false631 out.RawString("\"items\":")632 if in.Items == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {633 out.RawString("null")634 } else {635 out.RawByte('[')636 for v14, v15 := range in.Items {637 if v14 > 0 {638 out.RawByte(',')639 }640 if v15 == nil {641 out.RawString("null")642 } else {643 out.Raw((*v15).MarshalJSON())644 }645 }646 out.RawByte(']')647 }648 }649 out.RawByte('}')650}651// MarshalJSON supports json.Marshaler interface652func (v RawRenderItemList) MarshalJSON() ([]byte, error) {653 w := jwriter.Writer{}654 easyjson16bbae25EncodeCadentServerSchemasMetrics5(&w, v)655 return w.Buffer.BuildBytes(), w.Error656}657// MarshalEasyJSON supports easyjson.Marshaler interface658func (v RawRenderItemList) MarshalEasyJSON(w *jwriter.Writer) {659 easyjson16bbae25EncodeCadentServerSchemasMetrics5(w, v)660}661// UnmarshalJSON supports json.Unmarshaler interface662func (v *RawRenderItemList) UnmarshalJSON(data []byte) error {663 r := jlexer.Lexer{Data: data}664 easyjson16bbae25DecodeCadentServerSchemasMetrics5(&r, v)665 return r.Error()666}667// UnmarshalEasyJSON supports easyjson.Unmarshaler interface668func (v *RawRenderItemList) UnmarshalEasyJSON(l *jlexer.Lexer) {669 easyjson16bbae25DecodeCadentServerSchemasMetrics5(l, v)670}671func easyjson16bbae25DecodeCadentServerSchemasMetrics6(in *jlexer.Lexer, out *RawRenderItem) {672 isTopLevel := in.IsStart()673 if in.IsNull() {674 if isTopLevel {675 in.Consumed()676 }677 in.Skip()678 return679 }680 in.Delim('{')681 for !in.IsDelim('}') {682 key := in.UnsafeString()683 in.WantColon()684 if in.IsNull() {685 in.Skip()686 in.WantComma()687 continue688 }689 switch key {690 case "metric":691 out.Metric = string(in.String())692 case "id":693 out.Id = string(in.String())694 case "real_start":695 out.RealStart = uint32(in.Uint32())696 case "real_end":697 out.RealEnd = uint32(in.Uint32())698 case "start":699 out.Start = uint32(in.Uint32())700 case "end":701 out.End = uint32(in.Uint32())702 case "step":703 out.Step = uint32(in.Uint32())704 case "agg_func":705 out.AggFunc = uint32(in.Uint32())706 case "tags":707 if in.IsNull() {708 in.Skip()709 out.Tags = nil710 } else {711 in.Delim('[')712 if !in.IsDelim(']') {713 out.Tags = make([]*repr.Tag, 0, 8)714 } else {715 out.Tags = []*repr.Tag{}716 }717 for !in.IsDelim(']') {718 var v16 *repr.Tag719 if in.IsNull() {720 in.Skip()721 v16 = nil722 } else {723 if v16 == nil {724 v16 = new(repr.Tag)725 }726 if data := in.Raw(); in.Ok() {727 in.AddError((*v16).UnmarshalJSON(data))728 }729 }730 out.Tags = append(out.Tags, v16)731 in.WantComma()732 }733 in.Delim(']')734 }735 case "meta_tags":736 if in.IsNull() {737 in.Skip()738 out.MetaTags = nil739 } else {740 in.Delim('[')741 if !in.IsDelim(']') {742 out.MetaTags = make([]*repr.Tag, 0, 8)743 } else {744 out.MetaTags = []*repr.Tag{}745 }746 for !in.IsDelim(']') {747 var v17 *repr.Tag748 if in.IsNull() {749 in.Skip()750 v17 = nil751 } else {752 if v17 == nil {753 v17 = new(repr.Tag)754 }755 if data := in.Raw(); in.Ok() {756 in.AddError((*v17).UnmarshalJSON(data))757 }758 }759 out.MetaTags = append(out.MetaTags, v17)760 in.WantComma()761 }762 in.Delim(']')763 }764 case "data":765 if in.IsNull() {766 in.Skip()767 out.Data = nil768 } else {769 in.Delim('[')770 if !in.IsDelim(']') {771 out.Data = make([]*RawDataPoint, 0, 8)772 } else {773 out.Data = []*RawDataPoint{}774 }775 for !in.IsDelim(']') {776 var v18 *RawDataPoint777 if in.IsNull() {778 in.Skip()779 v18 = nil780 } else {781 if v18 == nil {782 v18 = new(RawDataPoint)783 }784 easyjson16bbae25DecodeCadentServerSchemasMetrics7(in, &*v18)785 }786 out.Data = append(out.Data, v18)787 in.WantComma()788 }789 in.Delim(']')790 }791 case "in_cache":792 out.InCache = bool(in.Bool())793 case "using_cache":794 out.UsingCache = bool(in.Bool())795 default:796 in.SkipRecursive()797 }798 in.WantComma()799 }800 in.Delim('}')801 if isTopLevel {802 in.Consumed()803 }804}805func easyjson16bbae25EncodeCadentServerSchemasMetrics6(out *jwriter.Writer, in RawRenderItem) {806 out.RawByte('{')807 first := true808 _ = first809 if in.Metric != "" {810 if !first {811 out.RawByte(',')812 }813 first = false814 out.RawString("\"metric\":")815 out.String(string(in.Metric))816 }817 if in.Id != "" {818 if !first {819 out.RawByte(',')820 }821 first = false822 out.RawString("\"id\":")823 out.String(string(in.Id))824 }825 if in.RealStart != 0 {826 if !first {827 out.RawByte(',')828 }829 first = false830 out.RawString("\"real_start\":")831 out.Uint32(uint32(in.RealStart))832 }833 if in.RealEnd != 0 {834 if !first {835 out.RawByte(',')836 }837 first = false838 out.RawString("\"real_end\":")839 out.Uint32(uint32(in.RealEnd))840 }841 if in.Start != 0 {842 if !first {843 out.RawByte(',')844 }845 first = false846 out.RawString("\"start\":")847 out.Uint32(uint32(in.Start))848 }849 if in.End != 0 {850 if !first {851 out.RawByte(',')852 }853 first = false854 out.RawString("\"end\":")855 out.Uint32(uint32(in.End))856 }857 if in.Step != 0 {858 if !first {859 out.RawByte(',')860 }861 first = false862 out.RawString("\"step\":")863 out.Uint32(uint32(in.Step))864 }865 if in.AggFunc != 0 {866 if !first {867 out.RawByte(',')868 }869 first = false870 out.RawString("\"agg_func\":")871 out.Uint32(uint32(in.AggFunc))872 }873 if len(in.Tags) != 0 {874 if !first {875 out.RawByte(',')876 }877 first = false878 out.RawString("\"tags\":")879 if in.Tags == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {880 out.RawString("null")881 } else {882 out.RawByte('[')883 for v19, v20 := range in.Tags {884 if v19 > 0 {885 out.RawByte(',')886 }887 if v20 == nil {888 out.RawString("null")889 } else {890 out.Raw((*v20).MarshalJSON())891 }892 }893 out.RawByte(']')894 }895 }896 if len(in.MetaTags) != 0 {897 if !first {898 out.RawByte(',')899 }900 first = false901 out.RawString("\"meta_tags\":")902 if in.MetaTags == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {903 out.RawString("null")904 } else {905 out.RawByte('[')906 for v21, v22 := range in.MetaTags {907 if v21 > 0 {908 out.RawByte(',')909 }910 if v22 == nil {911 out.RawString("null")912 } else {913 out.Raw((*v22).MarshalJSON())914 }915 }916 out.RawByte(']')917 }918 }919 if len(in.Data) != 0 {920 if !first {921 out.RawByte(',')922 }923 first = false924 out.RawString("\"data\":")925 if in.Data == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {926 out.RawString("null")927 } else {928 out.RawByte('[')929 for v23, v24 := range in.Data {930 if v23 > 0 {931 out.RawByte(',')932 }933 if v24 == nil {934 out.RawString("null")935 } else {936 out.Raw((*v24).MarshalJSON())937 }938 }939 out.RawByte(']')940 }941 }942 if in.InCache {943 if !first {944 out.RawByte(',')945 }946 first = false947 out.RawString("\"in_cache\":")948 out.Bool(bool(in.InCache))949 }950 if in.UsingCache {951 if !first {952 out.RawByte(',')953 }954 first = false955 out.RawString("\"using_cache\":")956 out.Bool(bool(in.UsingCache))957 }958 out.RawByte('}')959}960// MarshalJSON supports json.Marshaler interface961func (v RawRenderItem) MarshalJSON() ([]byte, error) {962 w := jwriter.Writer{}963 easyjson16bbae25EncodeCadentServerSchemasMetrics6(&w, v)964 return w.Buffer.BuildBytes(), w.Error965}966// MarshalEasyJSON supports easyjson.Marshaler interface967func (v RawRenderItem) MarshalEasyJSON(w *jwriter.Writer) {968 easyjson16bbae25EncodeCadentServerSchemasMetrics6(w, v)969}970// UnmarshalJSON supports json.Unmarshaler interface971func (v *RawRenderItem) UnmarshalJSON(data []byte) error {972 r := jlexer.Lexer{Data: data}973 easyjson16bbae25DecodeCadentServerSchemasMetrics6(&r, v)974 return r.Error()975}976// UnmarshalEasyJSON supports easyjson.Unmarshaler interface977func (v *RawRenderItem) UnmarshalEasyJSON(l *jlexer.Lexer) {978 easyjson16bbae25DecodeCadentServerSchemasMetrics6(l, v)979}980func easyjson16bbae25DecodeCadentServerSchemasMetrics7(in *jlexer.Lexer, out *RawDataPoint) {981 isTopLevel := in.IsStart()982 if in.IsNull() {983 if isTopLevel {984 in.Consumed()985 }986 in.Skip()987 return988 }989 in.Delim('{')990 for !in.IsDelim('}') {991 key := in.UnsafeString()992 in.WantColon()993 if in.IsNull() {994 in.Skip()995 in.WantComma()996 continue997 }998 switch key {999 case "time":1000 out.Time = uint32(in.Uint32())1001 case "sum":1002 out.Sum = float64(in.Float64())1003 case "min":1004 out.Min = float64(in.Float64())1005 case "max":1006 out.Max = float64(in.Float64())1007 case "last":1008 out.Last = float64(in.Float64())1009 case "count":1010 out.Count = int64(in.Int64())1011 default:1012 in.SkipRecursive()1013 }1014 in.WantComma()1015 }1016 in.Delim('}')1017 if isTopLevel {1018 in.Consumed()1019 }1020}1021func easyjson16bbae25EncodeCadentServerSchemasMetrics7(out *jwriter.Writer, in RawDataPoint) {1022 out.RawByte('{')1023 first := true1024 _ = first1025 if in.Time != 0 {1026 if !first {1027 out.RawByte(',')1028 }1029 first = false1030 out.RawString("\"time\":")1031 out.Uint32(uint32(in.Time))1032 }1033 if in.Sum != 0 {1034 if !first {1035 out.RawByte(',')1036 }1037 first = false1038 out.RawString("\"sum\":")1039 out.Float64(float64(in.Sum))1040 }1041 if in.Min != 0 {1042 if !first {1043 out.RawByte(',')1044 }1045 first = false1046 out.RawString("\"min\":")1047 out.Float64(float64(in.Min))1048 }1049 if in.Max != 0 {1050 if !first {1051 out.RawByte(',')1052 }1053 first = false1054 out.RawString("\"max\":")1055 out.Float64(float64(in.Max))1056 }1057 if in.Last != 0 {1058 if !first {1059 out.RawByte(',')1060 }1061 first = false1062 out.RawString("\"last\":")1063 out.Float64(float64(in.Last))1064 }1065 if in.Count != 0 {1066 if !first {1067 out.RawByte(',')1068 }1069 first = false1070 out.RawString("\"count\":")1071 out.Int64(int64(in.Count))1072 }1073 out.RawByte('}')1074}1075func easyjson16bbae25DecodeCadentServerSchemasMetrics8(in *jlexer.Lexer, out *RenderItemList) {1076 isTopLevel := in.IsStart()1077 if in.IsNull() {1078 if isTopLevel {1079 in.Consumed()1080 }1081 in.Skip()1082 return1083 }1084 in.Delim('{')1085 for !in.IsDelim('}') {1086 key := in.UnsafeString()1087 in.WantColon()1088 if in.IsNull() {1089 in.Skip()1090 in.WantComma()1091 continue1092 }1093 switch key {1094 case "items":1095 if in.IsNull() {1096 in.Skip()1097 out.Items = nil1098 } else {1099 in.Delim('[')1100 if !in.IsDelim(']') {1101 out.Items = make([]*RenderItem, 0, 8)1102 } else {1103 out.Items = []*RenderItem{}1104 }1105 for !in.IsDelim(']') {1106 var v25 *RenderItem1107 if in.IsNull() {1108 in.Skip()1109 v25 = nil1110 } else {1111 if v25 == nil {1112 v25 = new(RenderItem)1113 }1114 if data := in.Raw(); in.Ok() {1115 in.AddError((*v25).UnmarshalJSON(data))1116 }1117 }1118 out.Items = append(out.Items, v25)1119 in.WantComma()1120 }1121 in.Delim(']')1122 }1123 default:1124 in.SkipRecursive()1125 }1126 in.WantComma()1127 }1128 in.Delim('}')1129 if isTopLevel {1130 in.Consumed()1131 }1132}1133func easyjson16bbae25EncodeCadentServerSchemasMetrics8(out *jwriter.Writer, in RenderItemList) {1134 out.RawByte('{')1135 first := true1136 _ = first1137 if len(in.Items) != 0 {1138 if !first {1139 out.RawByte(',')1140 }1141 first = false1142 out.RawString("\"items\":")1143 if in.Items == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {1144 out.RawString("null")1145 } else {1146 out.RawByte('[')1147 for v26, v27 := range in.Items {1148 if v26 > 0 {1149 out.RawByte(',')1150 }1151 if v27 == nil {1152 out.RawString("null")1153 } else {1154 out.Raw((*v27).MarshalJSON())1155 }1156 }1157 out.RawByte(']')1158 }1159 }1160 out.RawByte('}')1161}1162// MarshalJSON supports json.Marshaler interface1163func (v RenderItemList) MarshalJSON() ([]byte, error) {1164 w := jwriter.Writer{}1165 easyjson16bbae25EncodeCadentServerSchemasMetrics8(&w, v)1166 return w.Buffer.BuildBytes(), w.Error1167}1168// MarshalEasyJSON supports easyjson.Marshaler interface1169func (v RenderItemList) MarshalEasyJSON(w *jwriter.Writer) {1170 easyjson16bbae25EncodeCadentServerSchemasMetrics8(w, v)1171}1172// UnmarshalJSON supports json.Unmarshaler interface1173func (v *RenderItemList) UnmarshalJSON(data []byte) error {1174 r := jlexer.Lexer{Data: data}1175 easyjson16bbae25DecodeCadentServerSchemasMetrics8(&r, v)1176 return r.Error()1177}1178// UnmarshalEasyJSON supports easyjson.Unmarshaler interface1179func (v *RenderItemList) UnmarshalEasyJSON(l *jlexer.Lexer) {1180 easyjson16bbae25DecodeCadentServerSchemasMetrics8(l, v)1181}1182func easyjson16bbae25DecodeCadentServerSchemasMetrics9(in *jlexer.Lexer, out *RenderItem) {1183 isTopLevel := in.IsStart()1184 if in.IsNull() {1185 if isTopLevel {1186 in.Consumed()1187 }1188 in.Skip()1189 return1190 }1191 in.Delim('{')1192 for !in.IsDelim('}') {1193 key := in.UnsafeString()1194 in.WantColon()1195 if in.IsNull() {1196 in.Skip()1197 in.WantComma()1198 continue1199 }1200 switch key {1201 case "target":1202 out.Target = string(in.String())1203 case "dataPoints":1204 if in.IsNull() {1205 in.Skip()1206 out.DataPoints = nil1207 } else {1208 in.Delim('[')1209 if !in.IsDelim(']') {1210 out.DataPoints = make([]*DataPoint, 0, 8)1211 } else {1212 out.DataPoints = []*DataPoint{}1213 }1214 for !in.IsDelim(']') {1215 var v28 *DataPoint1216 if in.IsNull() {1217 in.Skip()1218 v28 = nil1219 } else {1220 if v28 == nil {1221 v28 = new(DataPoint)1222 }1223 easyjson16bbae25DecodeCadentServerSchemasMetrics2(in, &*v28)1224 }1225 out.DataPoints = append(out.DataPoints, v28)1226 in.WantComma()1227 }1228 in.Delim(']')1229 }1230 default:1231 in.SkipRecursive()1232 }1233 in.WantComma()1234 }1235 in.Delim('}')1236 if isTopLevel {1237 in.Consumed()1238 }1239}1240func easyjson16bbae25EncodeCadentServerSchemasMetrics9(out *jwriter.Writer, in RenderItem) {1241 out.RawByte('{')1242 first := true1243 _ = first1244 if in.Target != "" {1245 if !first {1246 out.RawByte(',')1247 }1248 first = false1249 out.RawString("\"target\":")1250 out.String(string(in.Target))1251 }1252 if len(in.DataPoints) != 0 {1253 if !first {1254 out.RawByte(',')1255 }1256 first = false1257 out.RawString("\"dataPoints\":")1258 if in.DataPoints == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {1259 out.RawString("null")1260 } else {1261 out.RawByte('[')1262 for v29, v30 := range in.DataPoints {1263 if v29 > 0 {1264 out.RawByte(',')1265 }1266 if v30 == nil {1267 out.RawString("null")1268 } else {1269 out.Raw((*v30).MarshalJSON())1270 }1271 }1272 out.RawByte(']')1273 }1274 }1275 out.RawByte('}')1276}1277// MarshalJSON supports json.Marshaler interface1278func (v RenderItem) MarshalJSON() ([]byte, error) {1279 w := jwriter.Writer{}1280 easyjson16bbae25EncodeCadentServerSchemasMetrics9(&w, v)1281 return w.Buffer.BuildBytes(), w.Error1282}1283// MarshalEasyJSON supports easyjson.Marshaler interface1284func (v RenderItem) MarshalEasyJSON(w *jwriter.Writer) {1285 easyjson16bbae25EncodeCadentServerSchemasMetrics9(w, v)1286}1287// UnmarshalJSON supports json.Unmarshaler interface1288func (v *RenderItem) UnmarshalJSON(data []byte) error {1289 r := jlexer.Lexer{Data: data}1290 easyjson16bbae25DecodeCadentServerSchemasMetrics9(&r, v)1291 return r.Error()1292}1293// UnmarshalEasyJSON supports easyjson.Unmarshaler interface1294func (v *RenderItem) UnmarshalEasyJSON(l *jlexer.Lexer) {1295 easyjson16bbae25DecodeCadentServerSchemasMetrics9(l, v)1296}...
metrics_easyjson.go
Source:metrics_easyjson.go
...68 w := jwriter.Writer{}69 easyjson2220f231EncodeCadentServerSchemasMetrics(&w, v)70 return w.Buffer.BuildBytes(), w.Error71}72// MarshalEasyJSON supports easyjson.Marshaler interface73func (v RawRenderItems) MarshalEasyJSON(w *jwriter.Writer) {74 easyjson2220f231EncodeCadentServerSchemasMetrics(w, v)75}76// UnmarshalJSON supports json.Unmarshaler interface77func (v *RawRenderItems) UnmarshalJSON(data []byte) error {78 r := jlexer.Lexer{Data: data}79 easyjson2220f231DecodeCadentServerSchemasMetrics(&r, v)80 return r.Error()81}82// UnmarshalEasyJSON supports easyjson.Unmarshaler interface83func (v *RawRenderItems) UnmarshalEasyJSON(l *jlexer.Lexer) {84 easyjson2220f231DecodeCadentServerSchemasMetrics(l, v)85}86func easyjson2220f231DecodeCadentServerSchemasMetrics1(in *jlexer.Lexer, out *GraphiteApiItems) {87 isTopLevel := in.IsStart()88 if in.IsNull() {89 in.Skip()90 *out = nil91 } else {92 in.Delim('[')93 if !in.IsDelim(']') {94 *out = make(GraphiteApiItems, 0, 8)95 } else {96 *out = GraphiteApiItems{}97 }98 for !in.IsDelim(']') {99 var v4 *GraphiteApiItem100 if in.IsNull() {101 in.Skip()102 v4 = nil103 } else {104 if v4 == nil {105 v4 = new(GraphiteApiItem)106 }107 if data := in.Raw(); in.Ok() {108 in.AddError((*v4).UnmarshalJSON(data))109 }110 }111 *out = append(*out, v4)112 in.WantComma()113 }114 in.Delim(']')115 }116 if isTopLevel {117 in.Consumed()118 }119}120func easyjson2220f231EncodeCadentServerSchemasMetrics1(out *jwriter.Writer, in GraphiteApiItems) {121 if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {122 out.RawString("null")123 } else {124 out.RawByte('[')125 for v5, v6 := range in {126 if v5 > 0 {127 out.RawByte(',')128 }129 if v6 == nil {130 out.RawString("null")131 } else {132 out.Raw((*v6).MarshalJSON())133 }134 }135 out.RawByte(']')136 }137}138// MarshalJSON supports json.Marshaler interface139func (v GraphiteApiItems) MarshalJSON() ([]byte, error) {140 w := jwriter.Writer{}141 easyjson2220f231EncodeCadentServerSchemasMetrics1(&w, v)142 return w.Buffer.BuildBytes(), w.Error143}144// MarshalEasyJSON supports easyjson.Marshaler interface145func (v GraphiteApiItems) MarshalEasyJSON(w *jwriter.Writer) {146 easyjson2220f231EncodeCadentServerSchemasMetrics1(w, v)147}148// UnmarshalJSON supports json.Unmarshaler interface149func (v *GraphiteApiItems) UnmarshalJSON(data []byte) error {150 r := jlexer.Lexer{Data: data}151 easyjson2220f231DecodeCadentServerSchemasMetrics1(&r, v)152 return r.Error()153}154// UnmarshalEasyJSON supports easyjson.Unmarshaler interface155func (v *GraphiteApiItems) UnmarshalEasyJSON(l *jlexer.Lexer) {156 easyjson2220f231DecodeCadentServerSchemasMetrics1(l, v)157}158func easyjson2220f231DecodeCadentServerSchemasMetrics2(in *jlexer.Lexer, out *RenderItems) {159 isTopLevel := in.IsStart()160 if in.IsNull() {161 in.Skip()162 *out = nil163 } else {164 in.Delim('[')165 if !in.IsDelim(']') {166 *out = make(RenderItems, 0, 8)167 } else {168 *out = RenderItems{}169 }170 for !in.IsDelim(']') {171 var v7 *RenderItem172 if in.IsNull() {173 in.Skip()174 v7 = nil175 } else {176 if v7 == nil {177 v7 = new(RenderItem)178 }179 if data := in.Raw(); in.Ok() {180 in.AddError((*v7).UnmarshalJSON(data))181 }182 }183 *out = append(*out, v7)184 in.WantComma()185 }186 in.Delim(']')187 }188 if isTopLevel {189 in.Consumed()190 }191}192func easyjson2220f231EncodeCadentServerSchemasMetrics2(out *jwriter.Writer, in RenderItems) {193 if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {194 out.RawString("null")195 } else {196 out.RawByte('[')197 for v8, v9 := range in {198 if v8 > 0 {199 out.RawByte(',')200 }201 if v9 == nil {202 out.RawString("null")203 } else {204 out.Raw((*v9).MarshalJSON())205 }206 }207 out.RawByte(']')208 }209}210// MarshalJSON supports json.Marshaler interface211func (v RenderItems) MarshalJSON() ([]byte, error) {212 w := jwriter.Writer{}213 easyjson2220f231EncodeCadentServerSchemasMetrics2(&w, v)214 return w.Buffer.BuildBytes(), w.Error215}216// MarshalEasyJSON supports easyjson.Marshaler interface217func (v RenderItems) MarshalEasyJSON(w *jwriter.Writer) {218 easyjson2220f231EncodeCadentServerSchemasMetrics2(w, v)219}220// UnmarshalJSON supports json.Unmarshaler interface221func (v *RenderItems) UnmarshalJSON(data []byte) error {222 r := jlexer.Lexer{Data: data}223 easyjson2220f231DecodeCadentServerSchemasMetrics2(&r, v)224 return r.Error()225}226// UnmarshalEasyJSON supports easyjson.Unmarshaler interface227func (v *RenderItems) UnmarshalEasyJSON(l *jlexer.Lexer) {228 easyjson2220f231DecodeCadentServerSchemasMetrics2(l, v)229}230func easyjson2220f231DecodeCadentServerSchemasMetrics3(in *jlexer.Lexer, out *DBSeriesList) {231 isTopLevel := in.IsStart()232 if in.IsNull() {233 in.Skip()234 *out = nil235 } else {236 in.Delim('[')237 if !in.IsDelim(']') {238 *out = make(DBSeriesList, 0, 8)239 } else {240 *out = DBSeriesList{}241 }242 for !in.IsDelim(']') {243 var v10 *DBSeries244 if in.IsNull() {245 in.Skip()246 v10 = nil247 } else {248 if v10 == nil {249 v10 = new(DBSeries)250 }251 if data := in.Raw(); in.Ok() {252 in.AddError((*v10).UnmarshalJSON(data))253 }254 }255 *out = append(*out, v10)256 in.WantComma()257 }258 in.Delim(']')259 }260 if isTopLevel {261 in.Consumed()262 }263}264func easyjson2220f231EncodeCadentServerSchemasMetrics3(out *jwriter.Writer, in DBSeriesList) {265 if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {266 out.RawString("null")267 } else {268 out.RawByte('[')269 for v11, v12 := range in {270 if v11 > 0 {271 out.RawByte(',')272 }273 if v12 == nil {274 out.RawString("null")275 } else {276 out.Raw((*v12).MarshalJSON())277 }278 }279 out.RawByte(']')280 }281}282// MarshalJSON supports json.Marshaler interface283func (v DBSeriesList) MarshalJSON() ([]byte, error) {284 w := jwriter.Writer{}285 easyjson2220f231EncodeCadentServerSchemasMetrics3(&w, v)286 return w.Buffer.BuildBytes(), w.Error287}288// MarshalEasyJSON supports easyjson.Marshaler interface289func (v DBSeriesList) MarshalEasyJSON(w *jwriter.Writer) {290 easyjson2220f231EncodeCadentServerSchemasMetrics3(w, v)291}292// UnmarshalJSON supports json.Unmarshaler interface293func (v *DBSeriesList) UnmarshalJSON(data []byte) error {294 r := jlexer.Lexer{Data: data}295 easyjson2220f231DecodeCadentServerSchemasMetrics3(&r, v)296 return r.Error()297}298// UnmarshalEasyJSON supports easyjson.Unmarshaler interface299func (v *DBSeriesList) UnmarshalEasyJSON(l *jlexer.Lexer) {300 easyjson2220f231DecodeCadentServerSchemasMetrics3(l, v)301}302func easyjson2220f231DecodeCadentServerSchemasMetrics4(in *jlexer.Lexer, out *DBSeries) {303 isTopLevel := in.IsStart()304 if in.IsNull() {305 if isTopLevel {306 in.Consumed()307 }308 in.Skip()309 return310 }311 in.Delim('{')312 for !in.IsDelim('}') {313 key := in.UnsafeString()314 in.WantColon()315 if in.IsNull() {316 in.Skip()317 in.WantComma()318 continue319 }320 switch key {321 case "Id":322 out.Id = in.Interface()323 case "Uid":324 out.Uid = string(in.String())325 case "Start":326 out.Start = int64(in.Int64())327 case "End":328 out.End = int64(in.Int64())329 case "Ptype":330 out.Ptype = uint8(in.Uint8())331 case "Pbytes":332 if in.IsNull() {333 in.Skip()334 out.Pbytes = nil335 } else {336 out.Pbytes = in.Bytes()337 }338 case "Resolution":339 out.Resolution = uint32(in.Uint32())340 case "TTL":341 out.TTL = uint32(in.Uint32())342 default:343 in.SkipRecursive()344 }345 in.WantComma()346 }347 in.Delim('}')348 if isTopLevel {349 in.Consumed()350 }351}352func easyjson2220f231EncodeCadentServerSchemasMetrics4(out *jwriter.Writer, in DBSeries) {353 out.RawByte('{')354 first := true355 _ = first356 if !first {357 out.RawByte(',')358 }359 first = false360 out.RawString("\"Id\":")361 if m, ok := in.Id.(json.Marshaler); ok {362 out.Raw(m.MarshalJSON())363 } else {364 out.Raw(json.Marshal(in.Id))365 }366 if !first {367 out.RawByte(',')368 }369 first = false370 out.RawString("\"Uid\":")371 out.String(string(in.Uid))372 if !first {373 out.RawByte(',')374 }375 first = false376 out.RawString("\"Start\":")377 out.Int64(int64(in.Start))378 if !first {379 out.RawByte(',')380 }381 first = false382 out.RawString("\"End\":")383 out.Int64(int64(in.End))384 if !first {385 out.RawByte(',')386 }387 first = false388 out.RawString("\"Ptype\":")389 out.Uint8(uint8(in.Ptype))390 if !first {391 out.RawByte(',')392 }393 first = false394 out.RawString("\"Pbytes\":")395 out.Base64Bytes(in.Pbytes)396 if !first {397 out.RawByte(',')398 }399 first = false400 out.RawString("\"Resolution\":")401 out.Uint32(uint32(in.Resolution))402 if !first {403 out.RawByte(',')404 }405 first = false406 out.RawString("\"TTL\":")407 out.Uint32(uint32(in.TTL))408 out.RawByte('}')409}410// MarshalJSON supports json.Marshaler interface411func (v DBSeries) MarshalJSON() ([]byte, error) {412 w := jwriter.Writer{}413 easyjson2220f231EncodeCadentServerSchemasMetrics4(&w, v)414 return w.Buffer.BuildBytes(), w.Error415}416// MarshalEasyJSON supports easyjson.Marshaler interface417func (v DBSeries) MarshalEasyJSON(w *jwriter.Writer) {418 easyjson2220f231EncodeCadentServerSchemasMetrics4(w, v)419}420// UnmarshalJSON supports json.Unmarshaler interface421func (v *DBSeries) UnmarshalJSON(data []byte) error {422 r := jlexer.Lexer{Data: data}423 easyjson2220f231DecodeCadentServerSchemasMetrics4(&r, v)424 return r.Error()425}426// UnmarshalEasyJSON supports easyjson.Unmarshaler interface427func (v *DBSeries) UnmarshalEasyJSON(l *jlexer.Lexer) {428 easyjson2220f231DecodeCadentServerSchemasMetrics4(l, v)429}...
json.go
Source:json.go
...129 for _, sample := range samples {130 sample := sample131 sample.Metric.Thresholds.Thresholds = o.thresholds[sample.Metric.Name]132 o.handleMetric(sample.Metric, jw)133 wrapSample(sample).MarshalEasyJSON(jw)134 jw.RawByte('\n')135 }136 }137 if _, err := jw.DumpTo(o.out); err != nil {138 // Skip metric if it can't be made into JSON or envelope is null.139 o.logger.WithError(err).Error("Sample couldn't be marshalled to JSON")140 }141 if count > 0 {142 o.logger.WithField("t", time.Since(start)).WithField("count", count).Debug("Wrote metrics to JSON")143 }144}145func (o *Output) handleMetric(m *metrics.Metric, jw *jwriter.Writer) {146 if _, ok := o.seenMetrics[m.Name]; ok {147 return148 }149 o.seenMetrics[m.Name] = struct{}{}150 wrapMetric(m).MarshalEasyJSON(jw)151 jw.RawByte('\n')152}...
MarshalEasyJSON
Using AI Code Generation
1import (2type Metrics struct {3}4func (m *Metrics) MarshalEasyJSON(w *jwriter.Writer) {5 w.RawByte('{')6 w.String("Name")7 w.RawByte(':')8 w.String(m.Name)9 w.RawByte(',')10 w.String("Value")11 w.RawByte(':')12 w.Float64(m.Value)13 w.RawByte('}')14}15func (m *Metrics) UnmarshalEasyJSON(in *jlexer.Lexer) {16 m.Name = in.String()17 in.Delim(',')18 m.Value = in.Float64()19 in.Delim('}')20}21func main() {22 m := &Metrics{Name: "cpu", Value: 0.5}23 b, err := easyjson.Marshal(m)24 if err != nil {25 fmt.Println("Error: ", err)26 }27 fmt.Println(string(b))28}29{"Name":"cpu","Value":0.5}
MarshalEasyJSON
Using AI Code Generation
1func main() {2 m := metrics.New(1, 2, 3)3 m.MarshalEasyJSON(os.Stdout)4}5func main() {6 m := metrics.New(1, 2, 3)7 m.UnmarshalEasyJSON(os.Stdin)8}9func main() {10 m := metrics.New(1, 2, 3)11 m.MarshalJSON()12}13func main() {14 m := metrics.New(1, 2, 3)15 m.UnmarshalJSON()16}17func main() {18 m := metrics.New(1, 2, 3)19 m.MarshalJSONBuf()20}21func main() {22 m := metrics.New(1, 2, 3)23 m.UnmarshalJSONBuf()24}25func main() {26 m := metrics.New(1, 2, 3)27 m.MarshalJSONFast()28}29func main() {30 m := metrics.New(1, 2, 3)31 m.UnmarshalJSONFast()32}33func main() {34 m := metrics.New(1, 2, 3)35 m.MarshalJSONFastBuf()36}37func main() {38 m := metrics.New(1, 2, 3)39 m.UnmarshalJSONFastBuf()40}41func main() {42 m := metrics.New(1, 2, 3)43 m.MarshalJSONFastBuf()44}
MarshalEasyJSON
Using AI Code Generation
1import (2type metrics struct {3}4func main() {5 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {6 m := metrics{StartTime: time.Now()}7 b, err := m.MarshalEasyJSON(nil)8 if err != nil {9 log.Fatal(err)10 }11 fmt.Fprintf(w, string(b))12 })13 log.Fatal(http.ListenAndServe(":8080", nil))14}15import (16type metrics struct {17}18func main() {19 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {20 m := metrics{}21 err := m.UnmarshalEasyJSON(nil)22 if err != nil {23 log.Fatal(err)24 }25 fmt.Fprintf(w, m.StartTime.String())26 })27 log.Fatal(http.ListenAndServe(":8080", nil))28}29import (30type metrics struct {31}32func main() {33 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {34 m := metrics{StartTime: time.Now()}35 b, err := m.MarshalJSON()36 if err != nil {37 log.Fatal(err)38 }39 fmt.Fprintf(w, string(b))40 })41 log.Fatal(http.ListenAndServe(":8080", nil))42}43import (44type metrics struct {45}46func main() {47 http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {48 m := metrics{}49 err := m.UnmarshalJSON(nil)50 if err != nil {51 log.Fatal(err)52 }53 fmt.Fprintf(w, m.StartTime.String())54 })55 log.Fatal(http.ListenAndServe(":8080", nil))56}
MarshalEasyJSON
Using AI Code Generation
1func main() {2 m.C = []int{3, 4, 5}3 m.D = []string{"6", "7", "8"}4 m.E = map[string]int{"9": 9, "10": 10}5 m.F = map[string]string{"11": "11", "12": "12"}6 m.G = map[int]string{13: "13", 14: "14"}7 m.H = map[int]int{15: 15, 16: 16}8 m.I = map[string][]int{"17": {17, 18, 19}, "20": {20, 21, 22}}9 m.J = map[string][]string{"23": {"23", "24", "25"}, "26": {"26", "27", "28"}}10 m.K = map[int][]int{29: {29, 30, 31}, 32: {32, 33, 34}}11 m.L = map[int][]string{35: {"35", "36", "37"}, 38: {"38", "39", "40"}}12 m.M = map[string]map[string]int{"41": {"42": 42, "43": 43}, "44": {"45": 45, "46": 46}}13 m.N = map[string]map[string]string{"47": {"48": "48", "49": "49"}, "50": {"51": "51", "52": "52"}}14 m.O = map[int]map[string]int{53: {"54": 54, "55": 55}, 56: {"57": 57, "58": 58}}15 m.P = map[int]map[string]string{59: {"60": "60", "61": "61"}, 62: {"63": "63", "64": "64"}}16 m.Q = map[string]map[int]int{"65": {66: 66, 67: 67}, "68": {69: 69, 70: 70}}17 m.R = map[string]map[int]string{"71": {72: "72", 73: "73"}, "74": {75: "75", 76: "76"}}
MarshalEasyJSON
Using AI Code Generation
1func main() {2 metrics = Metrics{1, 2, 3, 4}3 data, err := metrics.MarshalJSON()4 if err != nil {5 panic(err)6 }7 fmt.Println(string(data))8}9func main() {10 data := []byte(`{"a": 1, "b": 2, "c": 3, "d": 4}`)11 err := metrics.UnmarshalJSON(data)12 if err != nil {13 panic(err)14 }15 fmt.Println(metrics)16}17func main() {18 metrics = Metrics{1, 2, 3, 4}19 data, err := metrics.MarshalJSON()20 if err != nil {21 panic(err)22 }23 fmt.Println(string(data))24}25func main() {26 data := []byte(`{"a": 1, "b": 2, "c": 3, "d": 4}`)27 err := metrics.UnmarshalJSON(data)28 if err != nil {29 panic(err)30 }31 fmt.Println(metrics)32}33func main() {34 metrics = Metrics{1, 2, 3, 4}35 data, err := metrics.MarshalJSON()36 if err != nil {37 panic(err)38 }39 fmt.Println(string(data))40}41func main() {42 data := []byte(`{"a": 1, "b": 2, "c": 3, "d": 4}`)43 err := metrics.UnmarshalJSON(data)44 if err != nil {45 panic(err)46 }47 fmt.Println(metrics)48}49func main() {50 metrics = Metrics{1, 2, 3, 4}
MarshalEasyJSON
Using AI Code Generation
1func main() {2 m := metrics.New()3 m.Collect()4 m.MarshalEasyJSON(os.Stdout)5}6func main() {7 m := metrics.New()8 m.UnmarshalEasyJSON(os.Stdin)9 m.Collect()10 m.MarshalEasyJSON(os.Stdout)11}12func main() {13 m := metrics.New()14 m.Collect()15 m.MarshalEasyJSON(os.Stdout)16}17func main() {18 m := metrics.New()19 m.UnmarshalEasyJSON(os.Stdin)20 m.Collect()21 m.MarshalEasyJSON(os.Stdout)22}23func main() {24 m := metrics.New()25 m.Collect()26 m.MarshalEasyJSON(os.Stdout)27}28func main() {29 m := metrics.New()30 m.UnmarshalEasyJSON(os.Stdin)31 m.Collect()32 m.MarshalEasyJSON(os.Stdout)33}34func main() {35 m := metrics.New()36 m.Collect()37 m.MarshalEasyJSON(os.Stdout)38}39func main() {40 m := metrics.New()41 m.UnmarshalEasyJSON(os.Stdin)42 m.Collect()43 m.MarshalEasyJSON(os.Stdout)44}45func main() {46 m := metrics.New()47 m.Collect()48 m.MarshalEasyJSON(os.Stdout)49}50func main() {51 m := metrics.New()52 m.UnmarshalEasyJSON(os.Stdin)
MarshalEasyJSON
Using AI Code Generation
1func main() {2 m.MarshalEasyJSON(os.Stdout)3}4func main() {5 m.UnmarshalEasyJSON(os.Stdin)6 fmt.Println(m.CPU)7 fmt.Println(m.Memory)8 fmt.Println(m.Network)9 fmt.Println(m.Disk)10 fmt.Println(m.Metrics)11}12func main() {13 m.MarshalEasyJSON(os.Stdout)14}15func main() {16 m.UnmarshalEasyJSON(os.Stdin)17 fmt.Println(m.CPU)18 fmt.Println(m.Memory)19 fmt.Println(m.Network)20 fmt.Println(m.Disk)21 fmt.Println(m.Metrics)22}23func main() {24 m.MarshalEasyJSON(os.Stdout)25}26func main() {27 m.UnmarshalEasyJSON(os.Stdin)28 fmt.Println(m.CPU)29 fmt.Println(m.Memory)30 fmt.Println(m.Network)31 fmt.Println(m.Disk)32 fmt.Println(m.Metrics)33}34func main() {35 m.MarshalEasyJSON(os.Stdout)36}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!