diff --git a/encode_compile.go b/encode_compile.go index 58b289a..8262d91 100644 --- a/encode_compile.go +++ b/encode_compile.go @@ -104,8 +104,6 @@ func encodeCompileHead(ctx *encodeCompileContext) (*opcode, error) { typ = orgType } else if isPtr && typ.Implements(marshalJSONType) { typ = orgType - } else if isPtr && isIntOrUintType(typ) { - //typ = orgType } code, err := encodeCompile(ctx.withType(typ)) if err != nil { diff --git a/encode_vm_escaped.go b/encode_vm_escaped.go index 7bac7f0..a06e0b8 100644 --- a/encode_vm_escaped.go +++ b/encode_vm_escaped.go @@ -29,7 +29,12 @@ func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, o case opInt: p := load(ctxptr, code.idx) u64 := ptrToUint64(p) - b = appendInt(b, u64&code.mask, (u64>>code.rshiftNum)&1 == 1) + if (u64>>code.rshiftNum)&1 == 1 { + v := ^u64&code.mask + 1 + b = appendInt(b, -v, true) + } else { + b = appendInt(b, u64&code.mask, (u64>>code.rshiftNum)&1 == 1) + } b = encodeComma(b) code = code.next case opUint: