FWIW, the JSON structure totally makes sense: [ 1, "auth", 1, 0, { "1": { "rec": { "1": { "i32": 40002 }, "2": { "i64": 59311498 }, "3": { "str": "MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM" }, "4": { "str": "YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM" }, "5": { "map": [ "str", "str", 0, {} ] } } } } ]
https://jsoneditoronline.org is quite helpful to find out where these parentheses may come from :-) -----Ursprüngliche Nachricht----- From: C Bergström Sent: Monday, March 11, 2019 10:32 AM To: user@thrift.apache.org Subject: Python client vs C# client json/binary different.. a lot of extra comma!! (confused) Hi I'm really super stuck and kindly ask for some help. I'm working on a python based client, but seeing some correct or spurious extra comma and wondering what on earth am I doing wrong. For example [1,"auth",1,0, vs [1"auth"10 I swear my code is correct?!! (The C# version does work.. I tried reading the source, but it looked fine and it does work at the end of the day.) // I test with thrift compiler 12 and 13 git head auth_args.thrift ------------- namespace py auth_args struct Data { 1: required i32 project_id 2: required i64 uid 3: required string auth_token 4: required string version 5: map<string,string> kv } exception RtmGatedException { 1: i32 code 2: string reason } service AuthArgs { bool auth(1:i32 project_id 2:i64 uid 3:string auth_token 4:string version 5:map<string, string> kv) } ---------------- Swapped to JSON protocol just so I could get something readable Python New // Many extra comma and the end has a lot of extra parentheses load = '[1,"auth",1,0,{"1":{"rec":{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str","str",0,{}]}}}}]' C# example output just for testing = [1"auth"10{"1":{"i32":40002},"2":{"i64":59311498},"3":{"str":"MkEyMDcyOTQzQkE5NERBMTAyOUQwNURGRUI1Rjc3ODM"},"4":{"str":"YyMvdW5pdHksMS4wIGJldGEsMjAxNDEyMjM"},"5":{"map":["str""str"0{}}] Binary portocol for anyone with a batman decoder ring (I couldn't get the c++ debug tool to build :-/ ) I'm kinda concerned the magic bit is different.. How would I even change this in Python? ---------------- Python New \x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\x89\x05\x8a\x0b\x00\x03\x00\x00\x00 ED237CF629A6CD7AF601659A39CECFDC\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0 beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00 C# old working \x00\x00\x00\x82\x0f\xff\x00\x01\x00\x00\x00\x01\x00\x01\x00\x00\x00\x00\x80\x01\x00\x01\x00\x00\x00\x04auth\x00\x00\x00\x00\x08\x00\x01\x00\x00\x9cB\n\x00\x02\x00\x00\x00\x00\x03\xf7e#\x0b\x00\x03\x00\x00\x00 6E97028A8240EC2B8BB1C6C8932A6E60\x0b\x00\x04\x00\x00\x00\x1ac#/unity,1.0 beta,20141223\r\x00\x05\x0b\x0b\x00\x00\x00\x00\x00