Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Jul 10, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 22 Jan 2013 at 12:23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant