@afiune Maybe return the type as well?
()
| 38 | |
| 39 | // @afiune Maybe return the type as well? |
| 40 | func (dec *Decoder) getObject() (start int, end int, err error) { |
| 41 | // start cursor |
| 42 | for ; dec.cursor < dec.length || dec.read(); dec.cursor++ { |
| 43 | switch dec.data[dec.cursor] { |
| 44 | case ' ', '\n', '\t', '\r', ',': |
| 45 | continue |
| 46 | // is null |
| 47 | case 'n': |
| 48 | dec.cursor++ |
| 49 | err = dec.assertNull() |
| 50 | if err != nil { |
| 51 | return |
| 52 | } |
| 53 | // Set start & end to the same cursor to indicate the object |
| 54 | // is a null and should not be unmarshal |
| 55 | start = dec.cursor |
| 56 | end = dec.cursor |
| 57 | return |
| 58 | case 't': |
| 59 | start = dec.cursor |
| 60 | dec.cursor++ |
| 61 | err = dec.assertTrue() |
| 62 | if err != nil { |
| 63 | return |
| 64 | } |
| 65 | end = dec.cursor |
| 66 | dec.cursor++ |
| 67 | return |
| 68 | // is false |
| 69 | case 'f': |
| 70 | start = dec.cursor |
| 71 | dec.cursor++ |
| 72 | err = dec.assertFalse() |
| 73 | if err != nil { |
| 74 | return |
| 75 | } |
| 76 | end = dec.cursor |
| 77 | dec.cursor++ |
| 78 | return |
| 79 | // is an object |
| 80 | case '{': |
| 81 | start = dec.cursor |
| 82 | dec.cursor++ |
| 83 | end, err = dec.skipObject() |
| 84 | dec.cursor = end |
| 85 | return |
| 86 | // is string |
| 87 | case '"': |
| 88 | start = dec.cursor |
| 89 | dec.cursor++ |
| 90 | start, end, err = dec.getString() |
| 91 | start-- |
| 92 | dec.cursor = end |
| 93 | return |
| 94 | // is array |
| 95 | case '[': |
| 96 | start = dec.cursor |
| 97 | dec.cursor++ |
no test coverage detected