How to use UnmarshalJSON method of lib Package

Best K6 code snippet using lib.UnmarshalJSON

encode_type.go

Source:encode_type.go Github

copy

Full Screen

...29 tm_types "github.com/cosmos/amino-js/go/lib/tendermint/tendermint/types"30)31func EncodeMultiStoreProofOp(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {32 var o rootmulti.MultiStoreProofOp33 err = codec.UnmarshalJSON(bz, &o)34 if err != nil {35 return nil, err36 }37 if lengthPrefixed {38 bz2, err = codec.MarshalBinaryLengthPrefixed(o)39 } else {40 bz2, err = codec.MarshalBinaryBare(o)41 }42 if err != nil {43 return nil, err44 }45 return46}47func EncodeIAVLAbsenceOp(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {48 var o iavl.IAVLAbsenceOp49 err = codec.UnmarshalJSON(bz, &o)50 if err != nil {51 return nil, err52 }53 if lengthPrefixed {54 bz2, err = codec.MarshalBinaryLengthPrefixed(o)55 } else {56 bz2, err = codec.MarshalBinaryBare(o)57 }58 if err != nil {59 return nil, err60 }61 return62}63func EncodeIAVLValueOp(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {64 var o iavl.IAVLValueOp65 err = codec.UnmarshalJSON(bz, &o)66 if err != nil {67 return nil, err68 }69 if lengthPrefixed {70 bz2, err = codec.MarshalBinaryLengthPrefixed(o)71 } else {72 bz2, err = codec.MarshalBinaryBare(o)73 }74 if err != nil {75 return nil, err76 }77 return78}79func EncodePrivKeyLedgerSecp256k1(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {80 var o crypto.PrivKeyLedgerSecp256k181 err = codec.UnmarshalJSON(bz, &o)82 if err != nil {83 return nil, err84 }85 if lengthPrefixed {86 bz2, err = codec.MarshalBinaryLengthPrefixed(o)87 } else {88 bz2, err = codec.MarshalBinaryBare(o)89 }90 if err != nil {91 return nil, err92 }93 return94}95func EncodeInfo(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {96 var o keys.Info97 err = codec.UnmarshalJSON(bz, &o)98 if err != nil {99 return nil, err100 }101 if lengthPrefixed {102 bz2, err = codec.MarshalBinaryLengthPrefixed(o)103 } else {104 bz2, err = codec.MarshalBinaryBare(o)105 }106 if err != nil {107 return nil, err108 }109 return110}111func EncodeBIP44Params(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {112 var o hd.BIP44Params113 err = codec.UnmarshalJSON(bz, &o)114 if err != nil {115 return nil, err116 }117 if lengthPrefixed {118 bz2, err = codec.MarshalBinaryLengthPrefixed(o)119 } else {120 bz2, err = codec.MarshalBinaryBare(o)121 }122 if err != nil {123 return nil, err124 }125 return126}127func EncodeLocalInfo(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {128 var o keys.LocalInfo129 err = codec.UnmarshalJSON(bz, &o)130 if err != nil {131 return nil, err132 }133 if lengthPrefixed {134 bz2, err = codec.MarshalBinaryLengthPrefixed(o)135 } else {136 bz2, err = codec.MarshalBinaryBare(o)137 }138 if err != nil {139 return nil, err140 }141 return142}143func EncodeLedgerInfo(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {144 var o keys.LedgerInfo145 err = codec.UnmarshalJSON(bz, &o)146 if err != nil {147 return nil, err148 }149 if lengthPrefixed {150 bz2, err = codec.MarshalBinaryLengthPrefixed(o)151 } else {152 bz2, err = codec.MarshalBinaryBare(o)153 }154 if err != nil {155 return nil, err156 }157 return158}159func EncodeOfflineInfo(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {160 var o keys.OfflineInfo161 err = codec.UnmarshalJSON(bz, &o)162 if err != nil {163 return nil, err164 }165 if lengthPrefixed {166 bz2, err = codec.MarshalBinaryLengthPrefixed(o)167 } else {168 bz2, err = codec.MarshalBinaryBare(o)169 }170 if err != nil {171 return nil, err172 }173 return174}175func EncodeMultiInfo(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {176 var o keys.MultiInfo177 err = codec.UnmarshalJSON(bz, &o)178 if err != nil {179 return nil, err180 }181 if lengthPrefixed {182 bz2, err = codec.MarshalBinaryLengthPrefixed(o)183 } else {184 bz2, err = codec.MarshalBinaryBare(o)185 }186 if err != nil {187 return nil, err188 }189 return190}191func EncodeMsg(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {192 var o types.Msg193 err = codec.UnmarshalJSON(bz, &o)194 if err != nil {195 return nil, err196 }197 if lengthPrefixed {198 bz2, err = codec.MarshalBinaryLengthPrefixed(o)199 } else {200 bz2, err = codec.MarshalBinaryBare(o)201 }202 if err != nil {203 return nil, err204 }205 return206}207func EncodeTx(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {208 var o types.Tx209 err = codec.UnmarshalJSON(bz, &o)210 if err != nil {211 return nil, err212 }213 if lengthPrefixed {214 bz2, err = codec.MarshalBinaryLengthPrefixed(o)215 } else {216 bz2, err = codec.MarshalBinaryBare(o)217 }218 if err != nil {219 return nil, err220 }221 return222}223func EncodeAccount(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {224 var o auth.Account225 err = codec.UnmarshalJSON(bz, &o)226 if err != nil {227 return nil, err228 }229 if lengthPrefixed {230 bz2, err = codec.MarshalBinaryLengthPrefixed(o)231 } else {232 bz2, err = codec.MarshalBinaryBare(o)233 }234 if err != nil {235 return nil, err236 }237 return238}239func EncodeVestingAccount(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {240 var o auth.VestingAccount241 err = codec.UnmarshalJSON(bz, &o)242 if err != nil {243 return nil, err244 }245 if lengthPrefixed {246 bz2, err = codec.MarshalBinaryLengthPrefixed(o)247 } else {248 bz2, err = codec.MarshalBinaryBare(o)249 }250 if err != nil {251 return nil, err252 }253 return254}255func EncodeBaseAccount(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {256 var o auth.BaseAccount257 err = codec.UnmarshalJSON(bz, &o)258 if err != nil {259 return nil, err260 }261 if lengthPrefixed {262 bz2, err = codec.MarshalBinaryLengthPrefixed(o)263 } else {264 bz2, err = codec.MarshalBinaryBare(o)265 }266 if err != nil {267 return nil, err268 }269 return270}271func EncodeBaseVestingAccount(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {272 var o auth.BaseVestingAccount273 err = codec.UnmarshalJSON(bz, &o)274 if err != nil {275 return nil, err276 }277 if lengthPrefixed {278 bz2, err = codec.MarshalBinaryLengthPrefixed(o)279 } else {280 bz2, err = codec.MarshalBinaryBare(o)281 }282 if err != nil {283 return nil, err284 }285 return286}287func EncodeContinuousVestingAccount(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {288 var o auth.ContinuousVestingAccount289 err = codec.UnmarshalJSON(bz, &o)290 if err != nil {291 return nil, err292 }293 if lengthPrefixed {294 bz2, err = codec.MarshalBinaryLengthPrefixed(o)295 } else {296 bz2, err = codec.MarshalBinaryBare(o)297 }298 if err != nil {299 return nil, err300 }301 return302}303func EncodeDelayedVestingAccount(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {304 var o auth.DelayedVestingAccount305 err = codec.UnmarshalJSON(bz, &o)306 if err != nil {307 return nil, err308 }309 if lengthPrefixed {310 bz2, err = codec.MarshalBinaryLengthPrefixed(o)311 } else {312 bz2, err = codec.MarshalBinaryBare(o)313 }314 if err != nil {315 return nil, err316 }317 return318}319func EncodeStdTx(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {320 var o auth.StdTx321 err = codec.UnmarshalJSON(bz, &o)322 if err != nil {323 return nil, err324 }325 if lengthPrefixed {326 bz2, err = codec.MarshalBinaryLengthPrefixed(o)327 } else {328 bz2, err = codec.MarshalBinaryBare(o)329 }330 if err != nil {331 return nil, err332 }333 return334}335func EncodeMsgSend(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {336 var o bank.MsgSend337 err = codec.UnmarshalJSON(bz, &o)338 if err != nil {339 return nil, err340 }341 if lengthPrefixed {342 bz2, err = codec.MarshalBinaryLengthPrefixed(o)343 } else {344 bz2, err = codec.MarshalBinaryBare(o)345 }346 if err != nil {347 return nil, err348 }349 return350}351func EncodeMsgMultiSend(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {352 var o bank.MsgMultiSend353 err = codec.UnmarshalJSON(bz, &o)354 if err != nil {355 return nil, err356 }357 if lengthPrefixed {358 bz2, err = codec.MarshalBinaryLengthPrefixed(o)359 } else {360 bz2, err = codec.MarshalBinaryBare(o)361 }362 if err != nil {363 return nil, err364 }365 return366}367func EncodeMsgVerifyInvariant(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {368 var o crisis.MsgVerifyInvariant369 err = codec.UnmarshalJSON(bz, &o)370 if err != nil {371 return nil, err372 }373 if lengthPrefixed {374 bz2, err = codec.MarshalBinaryLengthPrefixed(o)375 } else {376 bz2, err = codec.MarshalBinaryBare(o)377 }378 if err != nil {379 return nil, err380 }381 return382}383func EncodeMsgWithdrawDelegatorReward(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {384 var o distribution.MsgWithdrawDelegatorReward385 err = codec.UnmarshalJSON(bz, &o)386 if err != nil {387 return nil, err388 }389 if lengthPrefixed {390 bz2, err = codec.MarshalBinaryLengthPrefixed(o)391 } else {392 bz2, err = codec.MarshalBinaryBare(o)393 }394 if err != nil {395 return nil, err396 }397 return398}399func EncodeMsgWithdrawValidatorCommission(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {400 var o distribution.MsgWithdrawValidatorCommission401 err = codec.UnmarshalJSON(bz, &o)402 if err != nil {403 return nil, err404 }405 if lengthPrefixed {406 bz2, err = codec.MarshalBinaryLengthPrefixed(o)407 } else {408 bz2, err = codec.MarshalBinaryBare(o)409 }410 if err != nil {411 return nil, err412 }413 return414}415func EncodeMsgSetWithdrawAddress(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {416 var o distribution.MsgSetWithdrawAddress417 err = codec.UnmarshalJSON(bz, &o)418 if err != nil {419 return nil, err420 }421 if lengthPrefixed {422 bz2, err = codec.MarshalBinaryLengthPrefixed(o)423 } else {424 bz2, err = codec.MarshalBinaryBare(o)425 }426 if err != nil {427 return nil, err428 }429 return430}431func EncodeContent(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {432 var o gov.Content433 err = codec.UnmarshalJSON(bz, &o)434 if err != nil {435 return nil, err436 }437 if lengthPrefixed {438 bz2, err = codec.MarshalBinaryLengthPrefixed(o)439 } else {440 bz2, err = codec.MarshalBinaryBare(o)441 }442 if err != nil {443 return nil, err444 }445 return446}447func EncodeMsgSubmitProposal(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {448 var o gov.MsgSubmitProposal449 err = codec.UnmarshalJSON(bz, &o)450 if err != nil {451 return nil, err452 }453 if lengthPrefixed {454 bz2, err = codec.MarshalBinaryLengthPrefixed(o)455 } else {456 bz2, err = codec.MarshalBinaryBare(o)457 }458 if err != nil {459 return nil, err460 }461 return462}463func EncodeMsgDeposit(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {464 var o gov.MsgDeposit465 err = codec.UnmarshalJSON(bz, &o)466 if err != nil {467 return nil, err468 }469 if lengthPrefixed {470 bz2, err = codec.MarshalBinaryLengthPrefixed(o)471 } else {472 bz2, err = codec.MarshalBinaryBare(o)473 }474 if err != nil {475 return nil, err476 }477 return478}479func EncodeMsgVote(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {480 var o gov.MsgVote481 err = codec.UnmarshalJSON(bz, &o)482 if err != nil {483 return nil, err484 }485 if lengthPrefixed {486 bz2, err = codec.MarshalBinaryLengthPrefixed(o)487 } else {488 bz2, err = codec.MarshalBinaryBare(o)489 }490 if err != nil {491 return nil, err492 }493 return494}495func EncodeTextProposal(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {496 var o gov.TextProposal497 err = codec.UnmarshalJSON(bz, &o)498 if err != nil {499 return nil, err500 }501 if lengthPrefixed {502 bz2, err = codec.MarshalBinaryLengthPrefixed(o)503 } else {504 bz2, err = codec.MarshalBinaryBare(o)505 }506 if err != nil {507 return nil, err508 }509 return510}511func EncodeSoftwareUpgradeProposal(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {512 var o gov.SoftwareUpgradeProposal513 err = codec.UnmarshalJSON(bz, &o)514 if err != nil {515 return nil, err516 }517 if lengthPrefixed {518 bz2, err = codec.MarshalBinaryLengthPrefixed(o)519 } else {520 bz2, err = codec.MarshalBinaryBare(o)521 }522 if err != nil {523 return nil, err524 }525 return526}527func EncodeMsgIBCTransfer(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {528 var o ibc.MsgIBCTransfer529 err = codec.UnmarshalJSON(bz, &o)530 if err != nil {531 return nil, err532 }533 if lengthPrefixed {534 bz2, err = codec.MarshalBinaryLengthPrefixed(o)535 } else {536 bz2, err = codec.MarshalBinaryBare(o)537 }538 if err != nil {539 return nil, err540 }541 return542}543func EncodeMsgIBCReceive(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {544 var o ibc.MsgIBCReceive545 err = codec.UnmarshalJSON(bz, &o)546 if err != nil {547 return nil, err548 }549 if lengthPrefixed {550 bz2, err = codec.MarshalBinaryLengthPrefixed(o)551 } else {552 bz2, err = codec.MarshalBinaryBare(o)553 }554 if err != nil {555 return nil, err556 }557 return558}559func EncodeParameterChangeProposal(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {560 var o params.ParameterChangeProposal561 err = codec.UnmarshalJSON(bz, &o)562 if err != nil {563 return nil, err564 }565 if lengthPrefixed {566 bz2, err = codec.MarshalBinaryLengthPrefixed(o)567 } else {568 bz2, err = codec.MarshalBinaryBare(o)569 }570 if err != nil {571 return nil, err572 }573 return574}575func EncodeMsgUnjail(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {576 var o slashing.MsgUnjail577 err = codec.UnmarshalJSON(bz, &o)578 if err != nil {579 return nil, err580 }581 if lengthPrefixed {582 bz2, err = codec.MarshalBinaryLengthPrefixed(o)583 } else {584 bz2, err = codec.MarshalBinaryBare(o)585 }586 if err != nil {587 return nil, err588 }589 return590}591func EncodeMsgCreateValidator(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {592 var o staking.MsgCreateValidator593 err = codec.UnmarshalJSON(bz, &o)594 if err != nil {595 return nil, err596 }597 if lengthPrefixed {598 bz2, err = codec.MarshalBinaryLengthPrefixed(o)599 } else {600 bz2, err = codec.MarshalBinaryBare(o)601 }602 if err != nil {603 return nil, err604 }605 return606}607func EncodeMsgEditValidator(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {608 var o staking.MsgEditValidator609 err = codec.UnmarshalJSON(bz, &o)610 if err != nil {611 return nil, err612 }613 if lengthPrefixed {614 bz2, err = codec.MarshalBinaryLengthPrefixed(o)615 } else {616 bz2, err = codec.MarshalBinaryBare(o)617 }618 if err != nil {619 return nil, err620 }621 return622}623func EncodeMsgDelegate(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {624 var o staking.MsgDelegate625 err = codec.UnmarshalJSON(bz, &o)626 if err != nil {627 return nil, err628 }629 if lengthPrefixed {630 bz2, err = codec.MarshalBinaryLengthPrefixed(o)631 } else {632 bz2, err = codec.MarshalBinaryBare(o)633 }634 if err != nil {635 return nil, err636 }637 return638}639func EncodeMsgUndelegate(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {640 var o staking.MsgUndelegate641 err = codec.UnmarshalJSON(bz, &o)642 if err != nil {643 return nil, err644 }645 if lengthPrefixed {646 bz2, err = codec.MarshalBinaryLengthPrefixed(o)647 } else {648 bz2, err = codec.MarshalBinaryBare(o)649 }650 if err != nil {651 return nil, err652 }653 return654}655func EncodeMsgBeginRedelegate(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {656 var o staking.MsgBeginRedelegate657 err = codec.UnmarshalJSON(bz, &o)658 if err != nil {659 return nil, err660 }661 if lengthPrefixed {662 bz2, err = codec.MarshalBinaryLengthPrefixed(o)663 } else {664 bz2, err = codec.MarshalBinaryBare(o)665 }666 if err != nil {667 return nil, err668 }669 return670}671func EncodeBlockchainMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {672 var o tm_blockchain.BlockchainMessage673 err = codec.UnmarshalJSON(bz, &o)674 if err != nil {675 return nil, err676 }677 if lengthPrefixed {678 bz2, err = codec.MarshalBinaryLengthPrefixed(o)679 } else {680 bz2, err = codec.MarshalBinaryBare(o)681 }682 if err != nil {683 return nil, err684 }685 return686}687func EncodeBcBlockRequestMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {688 var o tm_blockchain.BcBlockRequestMessage689 err = codec.UnmarshalJSON(bz, &o)690 if err != nil {691 return nil, err692 }693 if lengthPrefixed {694 bz2, err = codec.MarshalBinaryLengthPrefixed(o)695 } else {696 bz2, err = codec.MarshalBinaryBare(o)697 }698 if err != nil {699 return nil, err700 }701 return702}703func EncodeBcBlockResponseMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {704 var o tm_blockchain.BcBlockResponseMessage705 err = codec.UnmarshalJSON(bz, &o)706 if err != nil {707 return nil, err708 }709 if lengthPrefixed {710 bz2, err = codec.MarshalBinaryLengthPrefixed(o)711 } else {712 bz2, err = codec.MarshalBinaryBare(o)713 }714 if err != nil {715 return nil, err716 }717 return718}719func EncodeBcNoBlockResponseMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {720 var o tm_blockchain.BcNoBlockResponseMessage721 err = codec.UnmarshalJSON(bz, &o)722 if err != nil {723 return nil, err724 }725 if lengthPrefixed {726 bz2, err = codec.MarshalBinaryLengthPrefixed(o)727 } else {728 bz2, err = codec.MarshalBinaryBare(o)729 }730 if err != nil {731 return nil, err732 }733 return734}735func EncodeBcStatusResponseMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {736 var o tm_blockchain.BcStatusResponseMessage737 err = codec.UnmarshalJSON(bz, &o)738 if err != nil {739 return nil, err740 }741 if lengthPrefixed {742 bz2, err = codec.MarshalBinaryLengthPrefixed(o)743 } else {744 bz2, err = codec.MarshalBinaryBare(o)745 }746 if err != nil {747 return nil, err748 }749 return750}751func EncodeBcStatusRequestMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {752 var o tm_blockchain.BcStatusRequestMessage753 err = codec.UnmarshalJSON(bz, &o)754 if err != nil {755 return nil, err756 }757 if lengthPrefixed {758 bz2, err = codec.MarshalBinaryLengthPrefixed(o)759 } else {760 bz2, err = codec.MarshalBinaryBare(o)761 }762 if err != nil {763 return nil, err764 }765 return766}767func EncodeConsensusMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {768 var o tm_consensus.ConsensusMessage769 err = codec.UnmarshalJSON(bz, &o)770 if err != nil {771 return nil, err772 }773 if lengthPrefixed {774 bz2, err = codec.MarshalBinaryLengthPrefixed(o)775 } else {776 bz2, err = codec.MarshalBinaryBare(o)777 }778 if err != nil {779 return nil, err780 }781 return782}783func EncodeNewRoundStepMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {784 var o tm_consensus.NewRoundStepMessage785 err = codec.UnmarshalJSON(bz, &o)786 if err != nil {787 return nil, err788 }789 if lengthPrefixed {790 bz2, err = codec.MarshalBinaryLengthPrefixed(o)791 } else {792 bz2, err = codec.MarshalBinaryBare(o)793 }794 if err != nil {795 return nil, err796 }797 return798}799func EncodeNewValidBlockMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {800 var o tm_consensus.NewValidBlockMessage801 err = codec.UnmarshalJSON(bz, &o)802 if err != nil {803 return nil, err804 }805 if lengthPrefixed {806 bz2, err = codec.MarshalBinaryLengthPrefixed(o)807 } else {808 bz2, err = codec.MarshalBinaryBare(o)809 }810 if err != nil {811 return nil, err812 }813 return814}815func EncodeProposalMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {816 var o tm_consensus.ProposalMessage817 err = codec.UnmarshalJSON(bz, &o)818 if err != nil {819 return nil, err820 }821 if lengthPrefixed {822 bz2, err = codec.MarshalBinaryLengthPrefixed(o)823 } else {824 bz2, err = codec.MarshalBinaryBare(o)825 }826 if err != nil {827 return nil, err828 }829 return830}831func EncodeProposalPOLMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {832 var o tm_consensus.ProposalPOLMessage833 err = codec.UnmarshalJSON(bz, &o)834 if err != nil {835 return nil, err836 }837 if lengthPrefixed {838 bz2, err = codec.MarshalBinaryLengthPrefixed(o)839 } else {840 bz2, err = codec.MarshalBinaryBare(o)841 }842 if err != nil {843 return nil, err844 }845 return846}847func EncodeBlockPartMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {848 var o tm_consensus.BlockPartMessage849 err = codec.UnmarshalJSON(bz, &o)850 if err != nil {851 return nil, err852 }853 if lengthPrefixed {854 bz2, err = codec.MarshalBinaryLengthPrefixed(o)855 } else {856 bz2, err = codec.MarshalBinaryBare(o)857 }858 if err != nil {859 return nil, err860 }861 return862}863func EncodeVoteMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {864 var o tm_consensus.VoteMessage865 err = codec.UnmarshalJSON(bz, &o)866 if err != nil {867 return nil, err868 }869 if lengthPrefixed {870 bz2, err = codec.MarshalBinaryLengthPrefixed(o)871 } else {872 bz2, err = codec.MarshalBinaryBare(o)873 }874 if err != nil {875 return nil, err876 }877 return878}879func EncodeHasVoteMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {880 var o tm_consensus.HasVoteMessage881 err = codec.UnmarshalJSON(bz, &o)882 if err != nil {883 return nil, err884 }885 if lengthPrefixed {886 bz2, err = codec.MarshalBinaryLengthPrefixed(o)887 } else {888 bz2, err = codec.MarshalBinaryBare(o)889 }890 if err != nil {891 return nil, err892 }893 return894}895func EncodeVoteSetMaj23Message(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {896 var o tm_consensus.VoteSetMaj23Message897 err = codec.UnmarshalJSON(bz, &o)898 if err != nil {899 return nil, err900 }901 if lengthPrefixed {902 bz2, err = codec.MarshalBinaryLengthPrefixed(o)903 } else {904 bz2, err = codec.MarshalBinaryBare(o)905 }906 if err != nil {907 return nil, err908 }909 return910}911func EncodeVoteSetBitsMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {912 var o tm_consensus.VoteSetBitsMessage913 err = codec.UnmarshalJSON(bz, &o)914 if err != nil {915 return nil, err916 }917 if lengthPrefixed {918 bz2, err = codec.MarshalBinaryLengthPrefixed(o)919 } else {920 bz2, err = codec.MarshalBinaryBare(o)921 }922 if err != nil {923 return nil, err924 }925 return926}927func EncodeWALMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {928 var o tm_consensus.WALMessage929 err = codec.UnmarshalJSON(bz, &o)930 if err != nil {931 return nil, err932 }933 if lengthPrefixed {934 bz2, err = codec.MarshalBinaryLengthPrefixed(o)935 } else {936 bz2, err = codec.MarshalBinaryBare(o)937 }938 if err != nil {939 return nil, err940 }941 return942}943func EncodeMsgInfo(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {944 var o tm_consensus.MsgInfo945 err = codec.UnmarshalJSON(bz, &o)946 if err != nil {947 return nil, err948 }949 if lengthPrefixed {950 bz2, err = codec.MarshalBinaryLengthPrefixed(o)951 } else {952 bz2, err = codec.MarshalBinaryBare(o)953 }954 if err != nil {955 return nil, err956 }957 return958}959func EncodeTimeoutInfo(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {960 var o tm_consensus.TimeoutInfo961 err = codec.UnmarshalJSON(bz, &o)962 if err != nil {963 return nil, err964 }965 if lengthPrefixed {966 bz2, err = codec.MarshalBinaryLengthPrefixed(o)967 } else {968 bz2, err = codec.MarshalBinaryBare(o)969 }970 if err != nil {971 return nil, err972 }973 return974}975func EncodeEndHeightMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {976 var o tm_consensus.EndHeightMessage977 err = codec.UnmarshalJSON(bz, &o)978 if err != nil {979 return nil, err980 }981 if lengthPrefixed {982 bz2, err = codec.MarshalBinaryLengthPrefixed(o)983 } else {984 bz2, err = codec.MarshalBinaryBare(o)985 }986 if err != nil {987 return nil, err988 }989 return990}991func EncodePubKey(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {992 var o tm_crypto.PubKey993 err = codec.UnmarshalJSON(bz, &o)994 if err != nil {995 return nil, err996 }997 if lengthPrefixed {998 bz2, err = codec.MarshalBinaryLengthPrefixed(o)999 } else {1000 bz2, err = codec.MarshalBinaryBare(o)1001 }1002 if err != nil {1003 return nil, err1004 }1005 return1006}1007func EncodePrivKey(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1008 var o tm_crypto.PrivKey1009 err = codec.UnmarshalJSON(bz, &o)1010 if err != nil {1011 return nil, err1012 }1013 if lengthPrefixed {1014 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1015 } else {1016 bz2, err = codec.MarshalBinaryBare(o)1017 }1018 if err != nil {1019 return nil, err1020 }1021 return1022}1023func EncodePubKeyEd25519(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1024 var o tm_ed25519.PubKeyEd255191025 err = codec.UnmarshalJSON(bz, &o)1026 if err != nil {1027 return nil, err1028 }1029 if lengthPrefixed {1030 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1031 } else {1032 bz2, err = codec.MarshalBinaryBare(o)1033 }1034 if err != nil {1035 return nil, err1036 }1037 return1038}1039func EncodePrivKeyEd25519(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1040 var o tm_ed25519.PrivKeyEd255191041 err = codec.UnmarshalJSON(bz, &o)1042 if err != nil {1043 return nil, err1044 }1045 if lengthPrefixed {1046 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1047 } else {1048 bz2, err = codec.MarshalBinaryBare(o)1049 }1050 if err != nil {1051 return nil, err1052 }1053 return1054}1055func EncodePubKeySecp256k1(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1056 var o tm_secp256k1.PubKeySecp256k11057 err = codec.UnmarshalJSON(bz, &o)1058 if err != nil {1059 return nil, err1060 }1061 if lengthPrefixed {1062 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1063 } else {1064 bz2, err = codec.MarshalBinaryBare(o)1065 }1066 if err != nil {1067 return nil, err1068 }1069 return1070}1071func EncodePrivKeySecp256k1(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1072 var o tm_secp256k1.PrivKeySecp256k11073 err = codec.UnmarshalJSON(bz, &o)1074 if err != nil {1075 return nil, err1076 }1077 if lengthPrefixed {1078 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1079 } else {1080 bz2, err = codec.MarshalBinaryBare(o)1081 }1082 if err != nil {1083 return nil, err1084 }1085 return1086}1087func EncodePubKeyMultisigThreshold(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1088 var o tm_multisig.PubKeyMultisigThreshold1089 err = codec.UnmarshalJSON(bz, &o)1090 if err != nil {1091 return nil, err1092 }1093 if lengthPrefixed {1094 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1095 } else {1096 bz2, err = codec.MarshalBinaryBare(o)1097 }1098 if err != nil {1099 return nil, err1100 }1101 return1102}1103func EncodeEvidenceMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1104 var o tm_evidence.EvidenceMessage1105 err = codec.UnmarshalJSON(bz, &o)1106 if err != nil {1107 return nil, err1108 }1109 if lengthPrefixed {1110 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1111 } else {1112 bz2, err = codec.MarshalBinaryBare(o)1113 }1114 if err != nil {1115 return nil, err1116 }1117 return1118}1119func EncodeEvidenceListMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1120 var o tm_evidence.EvidenceListMessage1121 err = codec.UnmarshalJSON(bz, &o)1122 if err != nil {1123 return nil, err1124 }1125 if lengthPrefixed {1126 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1127 } else {1128 bz2, err = codec.MarshalBinaryBare(o)1129 }1130 if err != nil {1131 return nil, err1132 }1133 return1134}1135func EncodeMempoolMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1136 var o tm_mempool.MempoolMessage1137 err = codec.UnmarshalJSON(bz, &o)1138 if err != nil {1139 return nil, err1140 }1141 if lengthPrefixed {1142 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1143 } else {1144 bz2, err = codec.MarshalBinaryBare(o)1145 }1146 if err != nil {1147 return nil, err1148 }1149 return1150}1151func EncodeTxMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1152 var o tm_mempool.TxMessage1153 err = codec.UnmarshalJSON(bz, &o)1154 if err != nil {1155 return nil, err1156 }1157 if lengthPrefixed {1158 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1159 } else {1160 bz2, err = codec.MarshalBinaryBare(o)1161 }1162 if err != nil {1163 return nil, err1164 }1165 return1166}1167func EncodePacket(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1168 var o tm_conn.Packet1169 err = codec.UnmarshalJSON(bz, &o)1170 if err != nil {1171 return nil, err1172 }1173 if lengthPrefixed {1174 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1175 } else {1176 bz2, err = codec.MarshalBinaryBare(o)1177 }1178 if err != nil {1179 return nil, err1180 }1181 return1182}1183func EncodePacketPing(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1184 var o tm_conn.PacketPing1185 err = codec.UnmarshalJSON(bz, &o)1186 if err != nil {1187 return nil, err1188 }1189 if lengthPrefixed {1190 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1191 } else {1192 bz2, err = codec.MarshalBinaryBare(o)1193 }1194 if err != nil {1195 return nil, err1196 }1197 return1198}1199func EncodePacketPong(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1200 var o tm_conn.PacketPong1201 err = codec.UnmarshalJSON(bz, &o)1202 if err != nil {1203 return nil, err1204 }1205 if lengthPrefixed {1206 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1207 } else {1208 bz2, err = codec.MarshalBinaryBare(o)1209 }1210 if err != nil {1211 return nil, err1212 }1213 return1214}1215func EncodePacketMsg(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1216 var o tm_conn.PacketMsg1217 err = codec.UnmarshalJSON(bz, &o)1218 if err != nil {1219 return nil, err1220 }1221 if lengthPrefixed {1222 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1223 } else {1224 bz2, err = codec.MarshalBinaryBare(o)1225 }1226 if err != nil {1227 return nil, err1228 }1229 return1230}1231func EncodePexMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1232 var o tm_pex.PexMessage1233 err = codec.UnmarshalJSON(bz, &o)1234 if err != nil {1235 return nil, err1236 }1237 if lengthPrefixed {1238 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1239 } else {1240 bz2, err = codec.MarshalBinaryBare(o)1241 }1242 if err != nil {1243 return nil, err1244 }1245 return1246}1247func EncodePexRequestMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1248 var o tm_pex.PexRequestMessage1249 err = codec.UnmarshalJSON(bz, &o)1250 if err != nil {1251 return nil, err1252 }1253 if lengthPrefixed {1254 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1255 } else {1256 bz2, err = codec.MarshalBinaryBare(o)1257 }1258 if err != nil {1259 return nil, err1260 }1261 return1262}1263func EncodePexAddrsMessage(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1264 var o tm_pex.PexAddrsMessage1265 err = codec.UnmarshalJSON(bz, &o)1266 if err != nil {1267 return nil, err1268 }1269 if lengthPrefixed {1270 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1271 } else {1272 bz2, err = codec.MarshalBinaryBare(o)1273 }1274 if err != nil {1275 return nil, err1276 }1277 return1278}1279func EncodeRemoteSignerMsg(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1280 var o tm_privval.RemoteSignerMsg1281 err = codec.UnmarshalJSON(bz, &o)1282 if err != nil {1283 return nil, err1284 }1285 if lengthPrefixed {1286 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1287 } else {1288 bz2, err = codec.MarshalBinaryBare(o)1289 }1290 if err != nil {1291 return nil, err1292 }1293 return1294}1295func EncodePubKeyRequest(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1296 var o tm_privval.PubKeyRequest1297 err = codec.UnmarshalJSON(bz, &o)1298 if err != nil {1299 return nil, err1300 }1301 if lengthPrefixed {1302 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1303 } else {1304 bz2, err = codec.MarshalBinaryBare(o)1305 }1306 if err != nil {1307 return nil, err1308 }1309 return1310}1311func EncodePubKeyResponse(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1312 var o tm_privval.PubKeyResponse1313 err = codec.UnmarshalJSON(bz, &o)1314 if err != nil {1315 return nil, err1316 }1317 if lengthPrefixed {1318 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1319 } else {1320 bz2, err = codec.MarshalBinaryBare(o)1321 }1322 if err != nil {1323 return nil, err1324 }1325 return1326}1327func EncodeSignVoteRequest(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1328 var o tm_privval.SignVoteRequest1329 err = codec.UnmarshalJSON(bz, &o)1330 if err != nil {1331 return nil, err1332 }1333 if lengthPrefixed {1334 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1335 } else {1336 bz2, err = codec.MarshalBinaryBare(o)1337 }1338 if err != nil {1339 return nil, err1340 }1341 return1342}1343func EncodeSignedVoteResponse(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1344 var o tm_privval.SignedVoteResponse1345 err = codec.UnmarshalJSON(bz, &o)1346 if err != nil {1347 return nil, err1348 }1349 if lengthPrefixed {1350 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1351 } else {1352 bz2, err = codec.MarshalBinaryBare(o)1353 }1354 if err != nil {1355 return nil, err1356 }1357 return1358}1359func EncodeSignProposalRequest(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1360 var o tm_privval.SignProposalRequest1361 err = codec.UnmarshalJSON(bz, &o)1362 if err != nil {1363 return nil, err1364 }1365 if lengthPrefixed {1366 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1367 } else {1368 bz2, err = codec.MarshalBinaryBare(o)1369 }1370 if err != nil {1371 return nil, err1372 }1373 return1374}1375func EncodeSignedProposalResponse(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1376 var o tm_privval.SignedProposalResponse1377 err = codec.UnmarshalJSON(bz, &o)1378 if err != nil {1379 return nil, err1380 }1381 if lengthPrefixed {1382 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1383 } else {1384 bz2, err = codec.MarshalBinaryBare(o)1385 }1386 if err != nil {1387 return nil, err1388 }1389 return1390}1391func EncodePingRequest(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1392 var o tm_privval.PingRequest1393 err = codec.UnmarshalJSON(bz, &o)1394 if err != nil {1395 return nil, err1396 }1397 if lengthPrefixed {1398 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1399 } else {1400 bz2, err = codec.MarshalBinaryBare(o)1401 }1402 if err != nil {1403 return nil, err1404 }1405 return1406}1407func EncodePingResponse(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1408 var o tm_privval.PingResponse1409 err = codec.UnmarshalJSON(bz, &o)1410 if err != nil {1411 return nil, err1412 }1413 if lengthPrefixed {1414 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1415 } else {1416 bz2, err = codec.MarshalBinaryBare(o)1417 }1418 if err != nil {1419 return nil, err1420 }1421 return1422}1423func EncodeTMEventData(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1424 var o tm_types.TMEventData1425 err = codec.UnmarshalJSON(bz, &o)1426 if err != nil {1427 return nil, err1428 }1429 if lengthPrefixed {1430 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1431 } else {1432 bz2, err = codec.MarshalBinaryBare(o)1433 }1434 if err != nil {1435 return nil, err1436 }1437 return1438}1439func EncodeEventDataNewBlock(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1440 var o tm_types.EventDataNewBlock1441 err = codec.UnmarshalJSON(bz, &o)1442 if err != nil {1443 return nil, err1444 }1445 if lengthPrefixed {1446 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1447 } else {1448 bz2, err = codec.MarshalBinaryBare(o)1449 }1450 if err != nil {1451 return nil, err1452 }1453 return1454}1455func EncodeEventDataNewBlockHeader(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1456 var o tm_types.EventDataNewBlockHeader1457 err = codec.UnmarshalJSON(bz, &o)1458 if err != nil {1459 return nil, err1460 }1461 if lengthPrefixed {1462 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1463 } else {1464 bz2, err = codec.MarshalBinaryBare(o)1465 }1466 if err != nil {1467 return nil, err1468 }1469 return1470}1471func EncodeEventDataTx(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1472 var o tm_types.EventDataTx1473 err = codec.UnmarshalJSON(bz, &o)1474 if err != nil {1475 return nil, err1476 }1477 if lengthPrefixed {1478 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1479 } else {1480 bz2, err = codec.MarshalBinaryBare(o)1481 }1482 if err != nil {1483 return nil, err1484 }1485 return1486}1487func EncodeEventDataRoundState(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1488 var o tm_types.EventDataRoundState1489 err = codec.UnmarshalJSON(bz, &o)1490 if err != nil {1491 return nil, err1492 }1493 if lengthPrefixed {1494 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1495 } else {1496 bz2, err = codec.MarshalBinaryBare(o)1497 }1498 if err != nil {1499 return nil, err1500 }1501 return1502}1503func EncodeEventDataNewRound(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1504 var o tm_types.EventDataNewRound1505 err = codec.UnmarshalJSON(bz, &o)1506 if err != nil {1507 return nil, err1508 }1509 if lengthPrefixed {1510 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1511 } else {1512 bz2, err = codec.MarshalBinaryBare(o)1513 }1514 if err != nil {1515 return nil, err1516 }1517 return1518}1519func EncodeEventDataCompleteProposal(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1520 var o tm_types.EventDataCompleteProposal1521 err = codec.UnmarshalJSON(bz, &o)1522 if err != nil {1523 return nil, err1524 }1525 if lengthPrefixed {1526 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1527 } else {1528 bz2, err = codec.MarshalBinaryBare(o)1529 }1530 if err != nil {1531 return nil, err1532 }1533 return1534}1535func EncodeEventDataVote(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1536 var o tm_types.EventDataVote1537 err = codec.UnmarshalJSON(bz, &o)1538 if err != nil {1539 return nil, err1540 }1541 if lengthPrefixed {1542 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1543 } else {1544 bz2, err = codec.MarshalBinaryBare(o)1545 }1546 if err != nil {1547 return nil, err1548 }1549 return1550}1551func EncodeEventDataValidatorSetUpdates(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1552 var o tm_types.EventDataValidatorSetUpdates1553 err = codec.UnmarshalJSON(bz, &o)1554 if err != nil {1555 return nil, err1556 }1557 if lengthPrefixed {1558 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1559 } else {1560 bz2, err = codec.MarshalBinaryBare(o)1561 }1562 if err != nil {1563 return nil, err1564 }1565 return1566}1567func EncodeEventDataString(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1568 var o tm_types.EventDataString1569 err = codec.UnmarshalJSON(bz, &o)1570 if err != nil {1571 return nil, err1572 }1573 if lengthPrefixed {1574 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1575 } else {1576 bz2, err = codec.MarshalBinaryBare(o)1577 }1578 if err != nil {1579 return nil, err1580 }1581 return1582}1583func EncodeEvidence(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1584 var o tm_types.Evidence1585 err = codec.UnmarshalJSON(bz, &o)1586 if err != nil {1587 return nil, err1588 }1589 if lengthPrefixed {1590 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1591 } else {1592 bz2, err = codec.MarshalBinaryBare(o)1593 }1594 if err != nil {1595 return nil, err1596 }1597 return1598}1599func EncodeDuplicateVoteEvidence(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1600 var o tm_types.DuplicateVoteEvidence1601 err = codec.UnmarshalJSON(bz, &o)1602 if err != nil {1603 return nil, err1604 }1605 if lengthPrefixed {1606 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1607 } else {1608 bz2, err = codec.MarshalBinaryBare(o)1609 }1610 if err != nil {1611 return nil, err1612 }1613 return1614}1615func EncodeMockGoodEvidence(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1616 var o tm_types.MockGoodEvidence1617 err = codec.UnmarshalJSON(bz, &o)1618 if err != nil {1619 return nil, err1620 }1621 if lengthPrefixed {1622 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1623 } else {1624 bz2, err = codec.MarshalBinaryBare(o)1625 }1626 if err != nil {1627 return nil, err1628 }1629 return1630}1631func EncodeMockRandomGoodEvidence(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1632 var o tm_types.MockRandomGoodEvidence1633 err = codec.UnmarshalJSON(bz, &o)1634 if err != nil {1635 return nil, err1636 }1637 if lengthPrefixed {1638 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1639 } else {1640 bz2, err = codec.MarshalBinaryBare(o)1641 }1642 if err != nil {1643 return nil, err1644 }1645 return1646}1647func EncodeMockBadEvidence(bz []byte, lengthPrefixed bool) (bz2 []byte, err error) {1648 var o tm_types.MockBadEvidence1649 err = codec.UnmarshalJSON(bz, &o)1650 if err != nil {1651 return nil, err1652 }1653 if lengthPrefixed {1654 bz2, err = codec.MarshalBinaryLengthPrefixed(o)1655 } else {1656 bz2, err = codec.MarshalBinaryBare(o)1657 }1658 if err != nil {1659 return nil, err1660 }1661 return1662}...

Full Screen

Full Screen

manifest_test.go

Source:manifest_test.go Github

copy

Full Screen

...26 }27 })28 }29}30func TestStringOrStrings_UnmarshalJSON(t *testing.T) {31 type args struct {32 data []byte33 }34 tests := []struct {35 name string36 l StringOrStrings37 args args38 wantErr bool39 }{40 {"license as a string", StringOrStrings{"test string"}, args{data: []byte("\"test string\"")}, false},41 {"one license as array", StringOrStrings{"(LGPL-2.1-only or GPL-3.0-or-later)"}, args{data: []byte("[\"(LGPL-2.1-only or GPL-3.0-or-later)\"]")}, false},42 {"two licenses as array", StringOrStrings{"LGPL-2.1-only", "GPL-3.0-or-later"}, args{data: []byte("[\"LGPL-2.1-only\", \"GPL-3.0-or-later\"]")}, false},43 {"error on non-string", StringOrStrings{""}, args{data: []byte("12345")}, true},44 }45 for _, tt := range tests {46 t.Run(tt.name, func(t *testing.T) {47 if err := tt.l.UnmarshalJSON(tt.args.data); (err != nil) != tt.wantErr {48 t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)49 }50 })51 }52}53func TestValueOrMap_MarshalJSON(t *testing.T) {54 type fields struct {55 Value string56 Patterns map[string]string57 }58 tests := []struct {59 name string60 fields fields61 want []byte62 wantErr bool63 }{64 {"single value", fields{Value: "one"}, []byte("\"one\""), false},65 {"another value", fields{Value: "auto"}, []byte("\"auto\""), false},66 {"multiple values", fields{Patterns: map[string]string{"one": "two", "three": "four"}}, []byte("{\"one\":\"two\",\"three\":\"four\"}"), false},67 }68 for _, tt := range tests {69 t.Run(tt.name, func(t *testing.T) {70 pi := &ValueOrMap{71 Value: tt.fields.Value,72 Map: tt.fields.Patterns,73 }74 got, err := pi.MarshalJSON()75 if (err != nil) != tt.wantErr {76 t.Errorf("MarshalJSON() error = %v, wantErr %v", err, tt.wantErr)77 return78 }79 if !reflect.DeepEqual(got, tt.want) {80 t.Errorf("MarshalJSON() got = %v, want %v", got, tt.want)81 }82 })83 }84}85func TestValueOrMap_UnmarshalJSON(t *testing.T) {86 type args struct {87 data []byte88 }89 tests := []struct {90 name string91 pi ValueOrMap92 args args93 wantErr bool94 }{95 {"single value", ValueOrMap{Value: "one"}, args{data: []byte("\"one\"")}, false},96 {"another value", ValueOrMap{Value: "auto"}, args{data: []byte("\"auto\"")}, false},97 {"multiple values", ValueOrMap{Map: map[string]string{"one": "two", "three": "four"}}, args{data: []byte("{\"one\":\"two\",\"three\":\"four\"}")}, false},98 {"error", ValueOrMap{}, args{data: []byte("true")}, true},99 }100 for _, tt := range tests {101 t.Run(tt.name, func(t *testing.T) {102 var pi ValueOrMap103 if err := pi.UnmarshalJSON(tt.args.data); (err != nil) != tt.wantErr {104 t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)105 }106 if !reflect.DeepEqual(tt.pi, pi) {107 t.Errorf("UnmarshalJSON() %v not equal to %v", tt.pi, pi)108 }109 })110 }111}112func TestBoolOrString_MarshalJSON(t *testing.T) {113 tests := []struct {114 name string115 s BoolOrString116 want []byte117 wantErr bool118 }{119 {"store", BoolOrString{Bool: true}, []byte("true"), false},120 {"do not store", BoolOrString{Bool: false}, []byte("false"), false},121 {"prompt", BoolOrString{String: "prompt"}, []byte("\"prompt\""), false},122 }123 for _, tt := range tests {124 t.Run(tt.name, func(t *testing.T) {125 got, err := tt.s.MarshalJSON()126 if (err != nil) != tt.wantErr {127 t.Errorf("MarshalJSON() error = %v, wantErr %v", err, tt.wantErr)128 return129 }130 if !reflect.DeepEqual(got, tt.want) {131 t.Errorf("MarshalJSON() got = %v, want %v", got, tt.want)132 }133 })134 }135}136func TestBoolOrString_UnmarshalJSON(t *testing.T) {137 type args struct {138 bytes []byte139 }140 tests := []struct {141 name string142 s BoolOrString143 args args144 wantErr bool145 }{146 {"true", BoolOrString{Bool: true}, args{[]byte("true")}, false},147 {"True", BoolOrString{Bool: true}, args{[]byte("True")}, false},148 {"1", BoolOrString{Bool: true}, args{[]byte("1")}, false},149 {"\"1\"", BoolOrString{Bool: true}, args{[]byte("\"1\"")}, false},150 {"false", BoolOrString{Bool: false}, args{[]byte("false")}, false},151 {"False", BoolOrString{Bool: false}, args{[]byte("False")}, false},152 {"0", BoolOrString{Bool: false}, args{[]byte("0")}, false},153 {"\"0\"", BoolOrString{Bool: false}, args{[]byte("\"0\"")}, false},154 {"prompt", BoolOrString{String: "prompt"}, args{[]byte("\"prompt\"")}, false},155 {"error", BoolOrString{}, args{[]byte("[\"error\"]")}, true},156 }157 for _, tt := range tests {158 var s BoolOrString159 t.Run(tt.name, func(t *testing.T) {160 if err := s.UnmarshalJSON(tt.args.bytes); (err != nil) != tt.wantErr {161 t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)162 }163 if !reflect.DeepEqual(tt.s, s) {164 t.Errorf("UnmarshalJSON() %v not equal to %v", tt.s, s)165 }166 })167 }168}169func TestIntString_MarshalJSON(t *testing.T) {170 tests := []struct {171 name string172 c IntString173 want []byte174 wantErr bool175 }{176 {"string 300", IntString("300"), []byte("\"300\""), false},177 {"string 300MiB", IntString("300MiB"), []byte("\"300MiB\""), false},178 }179 for _, tt := range tests {180 t.Run(tt.name, func(t *testing.T) {181 got, err := tt.c.MarshalJSON()182 if (err != nil) != tt.wantErr {183 t.Errorf("MarshalJSON() error = %v, wantErr %v", err, tt.wantErr)184 return185 }186 if !reflect.DeepEqual(got, tt.want) {187 t.Errorf("MarshalJSON() got = %v, want %v", got, tt.want)188 }189 })190 }191}192func TestIntString_UnmarshalJSON(t *testing.T) {193 type args struct {194 bytes []byte195 }196 tests := []struct {197 name string198 c IntString199 args args200 wantErr bool201 }{202 {"int 300", IntString("300"), args{[]byte("300")}, false},203 {"string 300", IntString("300"), args{[]byte("\"300\"")}, false},204 {"string 300MiB", IntString("300MiB"), args{[]byte("\"300MiB\"")}, false},205 }206 for _, tt := range tests {207 t.Run(tt.name, func(t *testing.T) {208 var c IntString209 if err := c.UnmarshalJSON(tt.args.bytes); (err != nil) != tt.wantErr {210 t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)211 }212 if !reflect.DeepEqual(tt.c, c) {213 t.Errorf("UnmarshalJSON() %v not equal to %v", tt.c, c)214 }215 })216 }217}218func TestBool_MarshalJSON(t *testing.T) {219 tests := []struct {220 name string221 b Bool222 want []byte223 wantErr bool224 }{225 {"true", Bool(true), []byte("true"), false},226 {"false", Bool(false), []byte("false"), false},227 }228 for _, tt := range tests {229 t.Run(tt.name, func(t *testing.T) {230 got, err := tt.b.MarshalJSON()231 if (err != nil) != tt.wantErr {232 t.Errorf("MarshalJSON() error = %v, wantErr %v", err, tt.wantErr)233 return234 }235 if !reflect.DeepEqual(got, tt.want) {236 t.Errorf("MarshalJSON() got = %v, want %v", got, tt.want)237 }238 })239 }240}241func TestBool_UnmarshalJSON(t *testing.T) {242 type args struct {243 bytes []byte244 }245 tests := []struct {246 name string247 b Bool248 args args249 wantErr bool250 }{251 {"true", Bool(true), args{[]byte("true")}, false},252 {"True", Bool(true), args{[]byte("True")}, false},253 {"1", Bool(true), args{[]byte("1")}, false},254 {"\"1\"", Bool(true), args{[]byte("\"1\"")}, false},255 {"false", Bool(false), args{[]byte("false")}, false},256 {"False", Bool(false), args{[]byte("False")}, false},257 {"0", Bool(false), args{[]byte("0")}, false},258 {"\"0\"", Bool(false), args{[]byte("\"0\"")}, false},259 {"error", Bool(false), args{[]byte("\"error\"")}, true},260 }261 for _, tt := range tests {262 t.Run(tt.name, func(t *testing.T) {263 var b Bool264 if err := b.UnmarshalJSON(tt.args.bytes); (err != nil) != tt.wantErr {265 t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)266 }267 if !reflect.DeepEqual(tt.b, b) {268 t.Errorf("UnmarshalJSON() %v not equal to %v", tt.b, b)269 }270 })271 }272}273func TestPsr_MarshalJSON(t *testing.T) {274 tests := []struct {275 name string276 p Psr277 want []byte278 wantErr bool279 }{280 {"\"UniqueGlobalClass\":\"\"", Psr(map[string][]string{"UniqueGlobalClass": {""}}), []byte("{\"UniqueGlobalClass\":[\"\"]}"), false},281 {"\"\":\"src/\"", Psr(map[string][]string{"": {"src/"}}), []byte("{\"\":[\"src/\"]}"), false},282 {"\"Monolog\\\\\":[\"src/\",\"lib/\"]", Psr(map[string][]string{"Monolog\\": {"src/", "lib/"}}), []byte("{\"Monolog\\\\\":[\"src/\",\"lib/\"]}"), false},283 }284 for _, tt := range tests {285 t.Run(tt.name, func(t *testing.T) {286 got, err := tt.p.MarshalJSON()287 if (err != nil) != tt.wantErr {288 t.Errorf("MarshalJSON() error = %v, wantErr %v", err, tt.wantErr)289 return290 }291 if !reflect.DeepEqual(got, tt.want) {292 t.Errorf("MarshalJSON() got = %v, want %v", got, tt.want)293 }294 })295 }296}297func TestPsr_UnmarshalJSON(t *testing.T) {298 type args struct {299 bytes []byte300 }301 tests := []struct {302 name string303 p Psr304 args args305 wantErr bool306 }{307 {"\"UniqueGlobalClass\":\"\"", Psr(map[string][]string{"UniqueGlobalClass": {""}}), args{[]byte("{\"UniqueGlobalClass\":[\"\"]}")}, false},308 {"\"\":\"src/\"", Psr(map[string][]string{"": {"src/"}}), args{[]byte("{\"\":\"src/\"}")}, false},309 {"\"\":\"src/\"", Psr(map[string][]string{"": {"src/"}}), args{[]byte("{\"\":\"src/\"}")}, false},310 {"\"Monolog\\\\\":\"src/\",\"Vendor_Namespace_\":[\"abc/\",\"lib/\"]", Psr(map[string][]string{"Monolog\\": {"src/"}, "Vendor_Namespace_": {"abc/", "lib/"}}), args{[]byte("{\"Monolog\\\\\":\"src/\",\"Vendor_Namespace_\":[\"abc/\",\"lib/\"]}")}, false},311 {"\"Monolog\\\\\":\"src/\",\"Vendor_Namespace_\":\"abc/\"", Psr(map[string][]string{"Monolog\\": {"src/"}, "Vendor_Namespace_": {"abc/"}}), args{[]byte("{\"Monolog\\\\\":\"src/\",\"Vendor_Namespace_\":[\"abc/\"]}")}, false},312 {"\"Monolog\\\\\":true", Psr(map[string][]string{}), args{[]byte("{\"Monolog\\\\\":true}")}, true},313 {"\"String\"", Psr(map[string][]string{}), args{[]byte("\"Monolog\"")}, true},314 }315 for _, tt := range tests {316 t.Run(tt.name, func(t *testing.T) {317 p := Psr(map[string][]string{})318 if err := p.UnmarshalJSON(tt.args.bytes); (err != nil) != tt.wantErr {319 t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)320 }321 if !reflect.DeepEqual(tt.p, p) {322 t.Errorf("UnmarshalJSON() %v not equal to %v", tt.p, p)323 }324 })325 }326}327func TestRepositories_MarshalJSON(t *testing.T) {328 tests := []struct {329 name string330 p Repositories331 want []byte332 wantErr bool333 }{334 {"1 repository", Repositories{Repository{Type: "test"}}, []byte("[{\"type\":\"test\"}]"), false},335 {"nothing", Repositories{}, []byte("[]"), false},336 }337 for _, tt := range tests {338 t.Run(tt.name, func(t *testing.T) {339 got, err := tt.p.MarshalJSON()340 if (err != nil) != tt.wantErr {341 t.Errorf("MarshalJSON() error = %v, wantErr %v", err, tt.wantErr)342 return343 }344 if !reflect.DeepEqual(got, tt.want) {345 t.Errorf("MarshalJSON() got = %d, want %v", got, tt.want)346 }347 })348 }349}350func TestRepositories_UnmarshalJSON(t *testing.T) {351 type args struct {352 bytes []byte353 }354 tests := []struct {355 name string356 p Repositories357 args args358 wantErr bool359 }{360 {"Array", Repositories{Repository{Type: "test"}}, args{[]byte("[{\"type\":\"test\"}]")}, false},361 {"Object", Repositories{Repository{Type: "test"}}, args{[]byte("{\"1\":{\"type\":\"test\"}}")}, false},362 {"Error", Repositories{}, args{[]byte("\"Nothing\"")}, true},363 }364 for _, tt := range tests {365 t.Run(tt.name, func(t *testing.T) {366 p := Repositories{}367 if err := p.UnmarshalJSON(tt.args.bytes); (err != nil) != tt.wantErr {368 t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr)369 }370 if !reflect.DeepEqual(tt.p, p) {371 t.Errorf("UnmarshalJSON() %v not equal to %v", tt.p, p)372 }373 })374 }375}...

Full Screen

Full Screen

UnmarshalJSON

Using AI Code Generation

copy

Full Screen

1import (2type Person struct {3}4func main() {5 bs := []byte(`{"First":"James", "Last":"Bond", "Age":20}`)6 json.Unmarshal(bs, &p1)7 fmt.Println(p1.First)8 fmt.Println(p1.Last)9 fmt.Println(p1.Age)10}

Full Screen

Full Screen

UnmarshalJSON

Using AI Code Generation

copy

Full Screen

1import (2type Student struct {3}4func (s *Student) UnmarshalJSON(data []byte) error {5 var v interface{}6 err := json.Unmarshal(data, &v)7 if err != nil {8 }9 m, ok := v.(map[string]interface{})10 if !ok {11 return fmt.Errorf("invalid json")12 }13 s.FirstName = m["first_name"].(string)14 s.LastName = m["last_name"].(string)15 s.Age = int(m["age"].(float64))16}17func main() {18 jsonStr := `{"first_name":"Rajeev", "last_name":"Kumar", "age": 30}`19 err := json.Unmarshal([]byte(jsonStr), &s)20 if err != nil {21 fmt.Println(err)22 }23 fmt.Println(s)24}

Full Screen

Full Screen

UnmarshalJSON

Using AI Code Generation

copy

Full Screen

1import (2type Person struct {3}4func (p *Person) UnmarshalJSON(data []byte) error {5 fmt.Println("Inside UnmarshalJSON")6 if err := json.Unmarshal(data, &age); err == nil {7 }8 if err := json.Unmarshal(data, &name); err == nil {9 }10 return fmt.Errorf("Could not unmarshal JSON")11}12func main() {13 if err := json.Unmarshal([]byte(`"John"`), &p); err != nil {14 fmt.Println(err)15 } else {16 fmt.Println(p)17 }18 if err := json.Unmarshal([]byte(`42`), &p); err != nil {19 fmt.Println(err)20 } else {21 fmt.Println(p)22 }23}

Full Screen

Full Screen

UnmarshalJSON

Using AI Code Generation

copy

Full Screen

1import (2type Student struct {3}4func (s *Student) UnmarshalJSON(data []byte) error {5 var temp struct {6 }7 err := json.Unmarshal(data, &temp)8 if err != nil {9 }10}11func main() {12 data := []byte(`{"Name":"John","Age":20}`)13 err := json.Unmarshal(data, &s)14 if err != nil {15 fmt.Println(err)16 }17 fmt.Println(s.Name)18 fmt.Println(s.Age)19}

Full Screen

Full Screen

UnmarshalJSON

Using AI Code Generation

copy

Full Screen

1import (2type student struct {3}4func main() {5 s := student{}6 data := []byte(`{"name":"John","age":30}`)7 json.Unmarshal(data, &s)8 fmt.Println(s)9}

Full Screen

Full Screen

UnmarshalJSON

Using AI Code Generation

copy

Full Screen

1import (2type Employee struct {3}4func (e *Employee) UnmarshalJSON(data []byte) error {5 var temp []interface{}6 err := json.Unmarshal(data, &temp)7 if err != nil {8 }9 e.Id = int(temp[0].(float64))10 e.Name = temp[1].(string)11 e.Age = int(temp[2].(float64))12}13func main() {14 jsonData := []byte(`[101,"Raj",30]`)15 json.Unmarshal(jsonData, &e)16 fmt.Println(e)17}

Full Screen

Full Screen

UnmarshalJSON

Using AI Code Generation

copy

Full Screen

1import (2type Person struct {3}4func (p *Person) UnmarshalJSON(bs []byte) error {5 err := json.Unmarshal(bs, &temp)6 if err != nil {7 }8 p.Age = int(temp[2][0])9}10func main() {

Full Screen

Full Screen

UnmarshalJSON

Using AI Code Generation

copy

Full Screen

1import (2type person struct {3}4func (p *person) UnmarshalJSON(b []byte) error {5 aux := &struct {6 }{7 Alias: (*Alias)(p),8 }9 if err := json.Unmarshal(b, &aux); err != nil {10 }11 p.Age, err = strconv.Atoi(aux.Age)12}13func main() {14 jsonFile, err := os.Open("data.json")15 if err != nil {16 log.Fatal(err)17 }18 defer jsonFile.Close()19 byteValue, _ := ioutil.ReadAll(jsonFile)20 json.Unmarshal(byteValue, &p)21 fmt.Println(p)22}

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run K6 automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful