decode should be used in cases where you will definitely have to use the entire decoded JSON structure, like printing it out to a string.
()
| 531 | // decode should be used in cases where you will definitely have to use the |
| 532 | // entire decoded JSON structure, like printing it out to a string. |
| 533 | func (j *jsonEncoded) decode() (JSON, error) { |
| 534 | switch j.typ { |
| 535 | case NumberJSONType: |
| 536 | _, j, err := decodeJSONNumber(j.value) |
| 537 | return j, err |
| 538 | case StringJSONType: |
| 539 | return jsonString(j.value), nil |
| 540 | case TrueJSONType: |
| 541 | return TrueJSONValue, nil |
| 542 | case FalseJSONType: |
| 543 | return FalseJSONValue, nil |
| 544 | case NullJSONType: |
| 545 | return NullJSONValue, nil |
| 546 | } |
| 547 | _, decoded, err := DecodeJSON(j.value) |
| 548 | |
| 549 | j.mu.Lock() |
| 550 | defer j.mu.Unlock() |
| 551 | j.mu.cachedDecoded = decoded |
| 552 | |
| 553 | return decoded, err |
| 554 | } |
| 555 | |
| 556 | func (j *jsonEncoded) AsText() (*string, error) { |
| 557 | if dec := j.alreadyDecoded(); dec != nil { |
no test coverage detected