|
| 1 | +# msgpack |
| 2 | + |
| 3 | +> :warning: DO NOT USE, STILL WIP! |
| 4 | +
|
| 5 | +At the minute, this module contains use-case-specific msgpack decoding improved for maximum performance. |
| 6 | + |
| 7 | +[See package documentation](https://pkg.go.dev/github.com/arivum/msgpack) |
| 8 | + |
| 9 | +## How to use |
| 10 | + |
| 11 | +```go |
| 12 | +package main |
| 13 | + |
| 14 | +import ( |
| 15 | + "fmt" |
| 16 | + "strings" |
| 17 | + |
| 18 | + "github.com/arivum/json2msgpackStreamer" |
| 19 | + "github.com/arivum/msgpack" |
| 20 | +) |
| 21 | + |
| 22 | +func main() { |
| 23 | + |
| 24 | + conv := json2msgpackStreamer.NewJSON2MsgPackStreamer(strings.NewReader( |
| 25 | + `{"a": "testvar", "b": ["b", "c"], "c": null, "d": false, "e": true, "g": -10, "f": -2.1, "h": "this is a longer text that needs a broader length indicator", "i": "sldkfj"} |
| 26 | +{"a": 4, "b": 18000000043000000233, "b2": -9000000043000000233, "c": null, "d": false, "e": true, "g": -10, "f": 2.0, "h": "this is a longer text that needs a broader length indicator", "i": "sldkfj"} |
| 27 | +{"a": "testvar", "b": ["b", "c"], "c": null} |
| 28 | +
|
| 29 | +{"a":"this is larger map test","b":"b","c":"c","d":"d","e":"e","f":"f","g":"g","h":"h","i":"i","j":"j","k":"k","l":"l","m":"m","n":"n","o":"o","p":"p","q": 1} |
| 30 | +
|
| 31 | +{"cmplx": {"a":"this is larger map test","b":"b","c":"c","d":"d","e":"e","f":"f","g":"g","h":"h","i":"i","j":"j","k":"k","l":"l","m":"m","n":"n","o":"o","p":"p","q": 1}} |
| 32 | +
|
| 33 | +["this is a larger slice test", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o"] |
| 34 | +
|
| 35 | +{"cmplx": ["2nd", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"]} |
| 36 | +`, |
| 37 | + )) |
| 38 | + |
| 39 | + d := msgpack.NewDecoder(conv) |
| 40 | + for entry := range d.Stream() { |
| 41 | + fmt.Printf("%+v\n", entry) |
| 42 | + } |
| 43 | + fmt.Println(d.LastError()) |
| 44 | +} |
| 45 | + |
| 46 | +``` |
0 commit comments