(buf *bytes.Buffer)
| 808 | func (jsonTrue) Format(buf *bytes.Buffer) { buf.WriteString("true") } |
| 809 | |
| 810 | func (j jsonNumber) Format(buf *bytes.Buffer) { |
| 811 | dec := apd.Decimal(j) |
| 812 | // Make sure non-finite values are encoded as valid strings by |
| 813 | // quoting them. Unfortunately, since this is JSON, there's no |
| 814 | // defined way to express the three special numeric values (+inf, |
| 815 | // -inf, nan) except as a string. This means that the decoding |
| 816 | // side can't tell whether the field should be a float or a |
| 817 | // string. Testing for exact types is thus tricky. As of this |
| 818 | // comment, our current tests for this behavior happen it the SQL |
| 819 | // package, not here in the JSON package. |
| 820 | nonfinite := dec.Form != apd.Finite |
| 821 | if nonfinite { |
| 822 | buf.WriteByte('"') |
| 823 | } |
| 824 | buf.WriteString(dec.String()) |
| 825 | if nonfinite { |
| 826 | buf.WriteByte('"') |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | func (j jsonString) Format(buf *bytes.Buffer) { |
| 831 | encodeJSONString(buf, string(j)) |
no test coverage detected