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.
()
| 517 | // decode should be used in cases where you will definitely have to use the |
| 518 | // entire decoded JSON structure, like printing it out to a string. |
| 519 | func (j *jsonEncoded) decode() (JSON, error) { |
| 520 | switch j.typ { |
| 521 | case NumberJSONType: |
| 522 | _, j, err := decodeJSONNumber(j.value) |
| 523 | return j, err |
| 524 | case StringJSONType: |
| 525 | return jsonString(j.value), nil |
| 526 | case TrueJSONType: |
| 527 | return TrueJSONValue, nil |
| 528 | case FalseJSONType: |
| 529 | return FalseJSONValue, nil |
| 530 | case NullJSONType: |
| 531 | return NullJSONValue, nil |
| 532 | } |
| 533 | _, decoded, err := DecodeJSON(j.value) |
| 534 | |
| 535 | j.mu.Lock() |
| 536 | defer j.mu.Unlock() |
| 537 | j.mu.cachedDecoded = decoded |
| 538 | |
| 539 | return decoded, err |
| 540 | } |
| 541 | |
| 542 | func (j *jsonEncoded) AsText() (*string, error) { |
| 543 | if dec := j.alreadyDecoded(); dec != nil { |
no test coverage detected