HasKey returns whether the map in 'raw' has a field with key 'key'
(key string, raw []byte)
| 53 | // HasKey returns whether the map in 'raw' has |
| 54 | // a field with key 'key' |
| 55 | func HasKey(key string, raw []byte) bool { |
| 56 | sz, bts, err := ReadMapHeaderBytes(raw) |
| 57 | if err != nil { |
| 58 | return false |
| 59 | } |
| 60 | var field []byte |
| 61 | for range sz { |
| 62 | field, bts, err = ReadStringZC(bts) |
| 63 | if err != nil { |
| 64 | return false |
| 65 | } |
| 66 | if UnsafeString(field) == key { |
| 67 | return true |
| 68 | } |
| 69 | } |
| 70 | return false |
| 71 | } |
| 72 | |
| 73 | func replace(raw []byte, start int, end int, val []byte, inplace bool) []byte { |
| 74 | ll := end - start // length of segment to replace |
searching dependent graphs…