isJSONObject checks if the given bytes are a JSON object, and also whether it's an empty object or not.
(b []byte)
| 1394 | // isJSONObject checks if the given bytes are a JSON object, |
| 1395 | // and also whether it's an empty object or not. |
| 1396 | func isJSONObject(b []byte) (isJSONObject, isEmpty bool) { |
| 1397 | |
| 1398 | // Check if the byte slice starts with { and ends with } |
| 1399 | if len(b) < 2 || b[0] != 0x7b || b[len(b)-1] != 0x7d { |
| 1400 | return false, false |
| 1401 | } |
| 1402 | |
| 1403 | return true, len(b) == 2 |
| 1404 | } |
| 1405 | |
| 1406 | // injectJSONPropertyFromBytes injects val under the given key into b. |
| 1407 | func injectJSONPropertyFromBytes(b []byte, bIsEmpty bool, kvPairs []KVPairBytes) (newJSON []byte) { |
no outgoing calls
no test coverage detected