Skip to content

com.googlecode.protobuf.format.JsonFormat#escapeBytes handles '\a' incorrectly. '\a' is ivalid value for json. #45

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?
simple code example

import com.google.protobuf.ByteString;
import com.google.protobuf.Message;
import com.googlecode.protobuf.format.JsonFormat;
import com.viaden.network.yoga.core.api.YogaCoreDomain;

/**
 * protobuf message
 * <p/>
 * {@code message TestObject { required bytes data = 1; }}
 */
public class JacksonTest {

    private static final char BELL_CHARACTER = '\u0007';

    public static void main(String[] args) throws Exception {
        final YogaCoreDomain.TestObject.Builder testObject = YogaCoreDomain.TestObject.newBuilder();
        testObject.setData(ByteString.copyFrom(new byte[]{BELL_CHARACTER}));

        final Message.Builder builder = YogaCoreDomain.TestObject.getDefaultInstance().newBuilderForType();
        final String result = JsonFormat.printToString(builder.mergeFrom(testObject.build()).build());
    }
}

What is the expected output? What do you see instead?
expected:
{"data":"\u0007"}
actual
{"data":"\a"}

What version of the product are you using? On what operating system?
1.2

Please provide any additional information below.

Original issue reported on code.google.com by korolyov...@gmail.com on 22 Jan 2013 at 12:23

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions