google-code-export / protostuff

Automatically exported from code.google.com/p/protostuff
Apache License 2.0
1 stars 1 forks source link

JSON encoding with numeric=false does not use field names. #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Run this:
        try{
            JsonIOUtil.writeTo(System.out, (PLogin)msg, PLogin.getSchema(), false);
            JsonIOUtil.writeTo(System.out, (PLogin)msg, PLogin.getSchema(), true);
        }catch(Exception e){
            e.printStackTrace();
        }

And the output is this:
{"1":"Ant","2":"a","3":"feed"}
{"1":"Ant","2":"a","3":"feed"}

this is the schema:

message PLogin {
    required string userId = 1;
    required string password = 2;
    required string source = 3;
}

What is the expected output? What do you see instead?

I expected that when numeric=false that the field names are printed rather than 
the integer id, however both outputs are identical.

What version of the product are you using? On what operating system?
1.0.0.M7

Please provide any additional information below.

Was using 1.0.0. but upgraded to latest and the issue is still happening.

Original issue reported on code.google.com by anthony....@yahoo.co.uk on 14 Nov 2011 at 1:17

GoogleCodeExporter commented 9 years ago
If you haven't looked at 
http://code.google.com/p/protostuff/wiki/CompilerOptions, pls do.  You need to 
enable the option: generate_field_map

Original comment by david.yu...@gmail.com on 14 Nov 2011 at 1:37

GoogleCodeExporter commented 9 years ago
oh thanks, missed that.  Works perfect now 
{"userId":"Ant","password":"a","source":"feed"}

Original comment by anthony....@yahoo.co.uk on 14 Nov 2011 at 1:52