Last active
February 1, 2018 00:08
-
-
Save scalone/3340a70fecf6a30efee5584e345c672a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
type middlewareResponse struct { | |
Received json.RawMessage `json:"received"` | |
AuthSent json.RawMessage `json:"auth_sent"` | |
AuthReceived json.RawMessage `json:"auth_received"` | |
} | |
func main() { | |
in := `{"received":"{\"Code\":\"0\",\"Message\":null}","auth_sent":"\u003c?xml version='1.0'?\u003e\n\u003cDocument\u003e\n\t\u003cSumUpActivationRequest\u003e\n\t\t\u003cHdr\u003e\n\t\t\t\u003cMsgFctn\u003eSARQ\u003c/MsgFctn\u003e\n\t\t\u003c/Hdr\u003e \n\t\t\u003cActivationCode\u003e99999980\u003c/ActivationCode\u003e\n\t\t\u003cDeviceSerialNumber\u003e5A179615\u003c/DeviceSerialNumber\u003e\n\t\u003c/SumUpActivationRequest\u003e\n\u003c/Document\u003e\n\n","auth_received":"\u003c?xml version=\"1.0\"?\u003e\u003cDocument\u003e\u003cSumUpActivationResponse\u003e\u003cHdr\u003e\u003cMsgFctn\u003eSARQ\u003c/MsgFctn\u003e\u003c/Hdr\u003e\u003cSuccess\u003etrue\u003c/Success\u003e\u003cCode\u003e0\u003c/Code\u003e\u003c/SumUpActivationResponse\u003e\u003c/Document\u003e"}` | |
bytes := []byte(in) | |
var response middlewareResponse | |
err := json.Unmarshal(bytes, &response) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("%+v", response) | |
} | |
//{Received:[34 123 92 34 67 111 100 101 92 34 58 92 34 48 92 34 44 92 34 77 101 115 115 97 103 101 92 34 58 110 117 108 108 125 34] AuthSent:[34 92 117 48 48 51 99 63 120 109 108 32 118 101 114 115 105 111 110 61 39 49 46 48 39 63 92 117 48 48 51 101 92 110 92 117 48 48 51 99 68 111 99 117 109 101 110 116 92 117 48 48 51 101 92 110 92 116 92 117 48 48 51 99 83 117 109 85 112 65 99 116 105 118 97 116 105 111 110 82 101 113 117 101 115 116 92 117 48 48 51 101 92 110 92 116 92 116 92 117 48 48 51 99 72 100 114 92 117 48 48 51 101 92 110 92 116 92 116 92 116 92 117 48 48 51 99 77 115 103 70 99 116 110 92 117 48 48 51 101 83 65 82 81 92 117 48 48 51 99 47 77 115 103 70 99 116 110 92 117 48 48 51 101 92 110 92 116 92 116 92 117 48 48 51 99 47 72 100 114 92 117 48 48 51 101 32 32 92 110 92 116 92 116 92 117 48 48 51 99 65 99 116 105 118 97 116 105 111 110 67 111 100 101 92 117 48 48 51 101 57 57 57 57 57 57 56 48 92 117 48 48 51 99 47 65 99 116 105 118 97 116 105 111 110 67 111 100 101 92 117 48 48 51 101 92 110 92 116 92 116 92 117 48 48 51 99 68 101 118 105 99 101 83 101 114 105 97 108 78 117 109 98 101 114 92 117 48 48 51 101 53 65 49 55 57 54 49 53 92 117 48 48 51 99 47 68 101 118 105 99 101 83 101 114 105 97 108 78 117 109 98 101 114 92 117 48 48 51 101 92 110 92 116 92 117 48 48 51 99 47 83 117 109 85 112 65 99 116 105 118 97 116 105 111 110 82 101 113 117 101 115 116 92 117 48 48 51 101 92 110 92 117 48 48 51 99 47 68 111 99 117 109 101 110 116 92 117 48 48 51 101 92 110 92 110 34] AuthReceived:[34 92 117 48 48 51 99 63 120 109 108 32 118 101 114 115 105 111 110 61 92 34 49 46 48 92 34 63 92 117 48 48 51 101 92 117 48 48 51 99 68 111 99 117 109 101 110 116 92 117 48 48 51 101 92 117 48 48 51 99 83 117 109 85 112 65 99 116 105 118 97 116 105 111 110 82 101 115 112 111 110 115 101 92 117 48 48 51 101 92 117 48 48 51 99 72 100 114 92 117 48 48 51 101 92 117 48 48 51 99 77 115 103 70 99 116 110 92 117 48 48 51 101 83 65 82 81 92 117 48 48 51 99 47 77 115 103 70 99 116 110 92 117 48 48 51 101 92 117 48 48 51 99 47 72 100 114 92 117 48 48 51 101 92 117 48 48 51 99 83 117 99 99 101 115 115 92 117 48 48 51 101 116 114 117 101 92 117 48 48 51 99 47 83 117 99 99 101 115 115 92 117 48 48 51 101 92 117 48 48 51 99 67 111 100 101 92 117 48 48 51 101 48 92 117 48 48 51 99 47 67 111 100 101 92 117 48 48 51 101 92 117 48 48 51 99 47 83 117 109 85 112 65 99 116 105 118 97 116 105 111 110 82 101 115 112 111 110 115 101 92 117 48 48 51 101 92 117 48 48 51 99 47 68 111 99 117 109 101 110 116 92 117 48 48 51 101 34]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment