| 381 | } |
| 382 | |
| 383 | func (r *QueryBulkStateContentResponse) UnmarshalJSON(data []byte) error { |
| 384 | wireFormat := make(map[string]string) |
| 385 | err := json.Unmarshal(data, &wireFormat) |
| 386 | if err != nil { |
| 387 | return err |
| 388 | } |
| 389 | r.Rooms = make(map[string]map[gomatrixserverlib.StateKeyTuple]string) |
| 390 | for roomTuple, value := range wireFormat { |
| 391 | fields := strings.Split(roomTuple, "\x1F") |
| 392 | roomID := fields[0] |
| 393 | if r.Rooms[roomID] == nil { |
| 394 | r.Rooms[roomID] = make(map[gomatrixserverlib.StateKeyTuple]string) |
| 395 | } |
| 396 | r.Rooms[roomID][gomatrixserverlib.StateKeyTuple{ |
| 397 | EventType: fields[1], |
| 398 | StateKey: fields[2], |
| 399 | }] = value |
| 400 | } |
| 401 | return nil |
| 402 | } |
| 403 | |
| 404 | // MarshalJSON stringifies the StateKeyTuple keys so they can be sent over the wire in HTTP API mode. |
| 405 | func (r *QueryCurrentStateResponse) MarshalJSON() ([]byte, error) { |