You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Groups are treated as repeated `LEN` message-fields
75
75
-`LEN` will try to be parsed as sub-tree, but you can override with other types in `query` (for example if it tries to make a sub-message with part of a string)
76
76
77
+
## query-map
78
+
79
+
Many things (ui, `toJS`, `toProto`, cli) use `queryMap` which is just a map of `name` to `path:type`. Here is one that works well with [hearthstone test data](https://github.com/konsumer/rawproto/raw/master/test/hearthstone.bin):
80
+
81
+
```json
82
+
{
83
+
"id": "1.2.4.1:string",
84
+
"title": "1.2.4.5:string",
85
+
"company": "1.2.4.6:string",
86
+
"description": "1.2.4.7:string",
87
+
88
+
"media": "1.2.4.10",
89
+
90
+
"dimensions": "1.2.4.10.2",
91
+
"width": "1.2.4.10.2.3:uint",
92
+
"height": "1.2.4.10.2.4:uint",
93
+
94
+
"url": "1.2.4.10.5:string",
95
+
"type": "1.2.4.10.1:uint",
96
+
"bg": "1.2.4.10.15:string"
97
+
}
98
+
```
99
+
100
+
You can use any types, from above, and set the name to whatever you want.
101
+
77
102
## migration
78
103
79
104
I used to have the functionality of this lib split up into several other projects. Here is migration instructions, if you want to update to this one (recommended):
80
105
81
106
-[protobuf-decoder](https://github.com/konsumer/protobuf-decoder) - just use [site](https://konsumer.js.org/rawproto/). The code is [here](https://github.com/konsumer/rawproto/tree/master/ui)
82
-
-[rawprotoparse](https://github.com/konsumer/rawprotoparse) - this originally would create JSON from protobuf binary. If you were using this as-is, it had a lot of options, which have been merged into either `toJS` (see [tests](https://github.com/konsumer/rawproto/blob/master/test/json.test.js) for examples) or a custom field-mapper, which you can do with `walk()`. It may require a little bit more custom-code, if you ware not using it with defaults, but overall should work better, and merges shared code that was in both libs. Main thing is that regular `toJS`, without a custom-mapper, will make all values an array, since it's possible for any field ID to be found multiple times.
107
+
-[rawprotoparse](https://github.com/konsumer/rawprotoparse) - this originally would create JSON from protobuf binary. If you were using this as-is, it had a lot of options, which have been merged into either `toJS` (see [tests](https://github.com/konsumer/rawproto/blob/master/test/json.test.js) for examples.) It may require a little bit more custom-code, if you were not using it with defaults, but overall should work better, and merges shared code that was in both libs. Main thing is that regular `toJS`, without a custom-mapper, will make all values an array, since it's possible for any field ID to be found multiple times.
83
108
-[newrawprotoparser](https://github.com/konsumer/newrawprotoparser) - this was some of the start of ideas for this. No one is probly using this. Essentially, it's the same stuff in [path](https://github.com/konsumer/rawproto/blob/master/test/path.test.js)
84
109
-[protoquery](https://github.com/konsumer/protoquery) - this was some of the start of ideas for this. No one is probly using this. Essentially it's the same stuff in [query](https://github.com/konsumer/rawproto/blob/master/test/query.test.js)
85
110
- rawproto - This lib used to be able to do JSON and generate proto, and provided a different CLI. You should be able to use the new APIs to accomplish all the same stuff, but it may require a bit of a change to your code. Have a look at the [unit-tests](https://github.com/konsumer/rawproto/tree/master/test), to get an idea of how it works.
0 commit comments