forked from mirror/go-json
Add StructFieldOmitEmptyStringPtr
This commit is contained in:
parent
d933310ad4
commit
d59cdefc1d
1231
cover_string_test.go
1231
cover_string_test.go
File diff suppressed because it is too large
Load Diff
20
encode_vm.go
20
encode_vm.go
|
@ -7759,6 +7759,26 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyStringPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.key...)
|
||||
b = encodeNoEscapedString(b, e.ptrToString(p))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagStringPtr:
|
||||
b = append(b, code.key...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, e.ptrToString(p))))
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldBool:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.key...)
|
||||
|
|
|
@ -7745,6 +7745,26 @@ func (e *Encoder) runEscaped(ctx *encodeRuntimeContext, b []byte, code *opcode)
|
|||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyStringPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = append(b, code.escapedKey...)
|
||||
b = encodeNoEscapedString(b, e.ptrToString(p))
|
||||
b = encodeComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagStringPtr:
|
||||
b = append(b, code.escapedKey...)
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, e.ptrToString(p))))
|
||||
}
|
||||
b = encodeComma(b)
|
||||
code = code.next
|
||||
case opStructFieldBool:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
b = append(b, code.escapedKey...)
|
||||
|
|
|
@ -7552,6 +7552,43 @@ func (e *Encoder) runEscapedIndent(ctx *encodeRuntimeContext, b []byte, code *op
|
|||
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldStringPtr:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeEscapedString(b, e.ptrToString(p))
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyStringPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
b = encodeNoEscapedString(b, e.ptrToString(p))
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagStringPtr:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
b = append(b, ' ')
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, e.ptrToString(p))))
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldBool:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.escapedKey...)
|
||||
|
|
|
@ -7552,6 +7552,43 @@ func (e *Encoder) runIndent(ctx *encodeRuntimeContext, b []byte, code *opcode) (
|
|||
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s)))
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldStringPtr:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeNoEscapedString(b, e.ptrToString(p))
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldOmitEmptyStringPtr:
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p != 0 {
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
b = encodeNoEscapedString(b, e.ptrToString(p))
|
||||
b = encodeIndentComma(b)
|
||||
}
|
||||
code = code.next
|
||||
case opStructFieldStringTagStringPtr:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
b = append(b, ' ')
|
||||
ptr := load(ctxptr, code.headIdx)
|
||||
p := e.ptrToPtr(ptr + code.offset)
|
||||
if p == 0 {
|
||||
b = encodeNull(b)
|
||||
} else {
|
||||
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, e.ptrToString(p))))
|
||||
}
|
||||
b = encodeIndentComma(b)
|
||||
code = code.next
|
||||
case opStructFieldBool:
|
||||
b = e.encodeIndent(b, code.indent)
|
||||
b = append(b, code.key...)
|
||||
|
|
Loading…
Reference in New Issue