Documentation ¶
Overview ¶
Package orderedjson allows you to unmarshal JSON objects while maintaining the order of the keys.
Given this input: ```json
{ "0": null, "1": 0, "2": "s", "3": [null, 0, "string", [], {}], "4": {"0": null, "1": 0, "2": "s", "3": [], "4": {}}, }
```
Use the `orderedjson.Map` type to unmarshal:
```go
var object orderedjson.Map err := json.Unmarshal(input, &object) ```
The content of `object` will then be:
```go
object := orderedjson.Map{ {Key: json.RawMessage(`"0"`), Value: json.RawMessage(`null`)}, {Key: json.RawMessage(`"1"`), Value: json.RawMessage(`0`)}, {Key: json.RawMessage(`"2"`), Value: json.RawMessage(`"s"`)}, {Key: json.RawMessage(`"3"`), Value: json.RawMessage(`[null, 0, "string", [], {}]`)}, {Key: json.RawMessage(`"4"`), Value: json.RawMessage(`{"0": null, "1": 0, "2": "s", "3": [], "4": {}}`)}, }
```
And you can continue unmarshalling `Key` and `Value` however you wish.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map []MapEntry
Map contains the ordered keys that are parsed from the data.
func (Map) MarshalJSON ¶
func (*Map) UnmarshalJSON ¶
type MapEntry ¶
type MapEntry struct { Key json.RawMessage Value json.RawMessage }
MapEntry is a key-value in the unmarshaled JSON object.
Click to show internal directories.
Click to hide internal directories.