[jira] [Updated] (AVRO-1632) C++ JsonEncoder dosen't close braces of objects

2015-01-19 Thread JIRA

 [ 
https://issues.apache.org/jira/browse/AVRO-1632?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Heye Vöcking updated AVRO-1632:
---
Summary: C++ JsonEncoder dosen't close braces of objects  (was: JsonEncoder 
in Avro C++ dosen't close braces)

> C++ JsonEncoder dosen't close braces of objects
> ---
>
> Key: AVRO-1632
> URL: https://issues.apache.org/jira/browse/AVRO-1632
> Project: Avro
>  Issue Type: Bug
>  Components: c++
>Affects Versions: 1.7.7
> Environment: Ubuntu 12.04, gcc 4.6.4
>Reporter: Heye Vöcking
>  Labels: avro, c++, encode, json
>
> Please see the example.
> Expected output is:
> {noformat}
> result: '{"re":100.23,"im":105.77}'
> {noformat}
> Actual output is:
> {noformat}
> result: '{"re":100.23,"im":105.77'
> {noformat}
> {code:title=json_encode_example.cc|borderStyle=solid}
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include "cpx.hh"
> int
> main()
> {
> static size_t CHUNK_SIZE = 8 * 1024;
> std::ifstream ifs("examples/cpx.json");
> avro::ValidSchema cpxSchema;
> avro::compileJsonSchema(ifs, cpxSchema);
> std::auto_ptr out = 
> avro::memoryOutputStream(CHUNK_SIZE);
> avro::EncoderPtr e = avro::jsonEncoder(cpxSchema);
> e->init(*out);
> c::cpx c1;
> c1.re = 100.23;
> c1.im = 105.77;
> avro::encode(*e, c1);
> out->flush();
> std::cout << "out->byteCount(): " << out->byteCount() << std::endl;
> std::auto_ptr in = avro::memoryInputStream(*out);
> avro::StreamReader streamReader(*in);
> uint8_t jsonBytes[CHUNK_SIZE];
> size_t length = CHUNK_SIZE;
> streamReader.readBytes(jsonBytes, length);
> std::cout << "in->byteCount(): " << in->byteCount() << std::endl;
> std::cout << "result: \'" << jsonBytes << "\'" << std::endl;
> for (size_t i = 0; i < 30; i += 1) {
> printf("jsonBytes[%02zu]: 0x%02X (%c)\n", i, (unsigned char) 
> jsonBytes[i], jsonBytes[i]);
> }
> return 0;
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (AVRO-1632) C++ JsonEncoder dosen't close braces of objects

2015-01-19 Thread JIRA

 [ 
https://issues.apache.org/jira/browse/AVRO-1632?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Heye Vöcking updated AVRO-1632:
---
Labels: avro c++ encode json  (was: avro c++ encode infinite-loop json)

> C++ JsonEncoder dosen't close braces of objects
> ---
>
> Key: AVRO-1632
> URL: https://issues.apache.org/jira/browse/AVRO-1632
> Project: Avro
>  Issue Type: Bug
>  Components: c++
>Affects Versions: 1.7.7
> Environment: Ubuntu 12.04, gcc 4.6.4
>Reporter: Heye Vöcking
>  Labels: avro, c++, encode, json
>
> Please see the example.
> Expected output is:
> {noformat}
> result: '{"re":100.23,"im":105.77}'
> {noformat}
> Actual output is:
> {noformat}
> result: '{"re":100.23,"im":105.77'
> {noformat}
> {code:title=json_encode_example.cc|borderStyle=solid}
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include "cpx.hh"
> int
> main()
> {
> static size_t CHUNK_SIZE = 8 * 1024;
> std::ifstream ifs("examples/cpx.json");
> avro::ValidSchema cpxSchema;
> avro::compileJsonSchema(ifs, cpxSchema);
> std::auto_ptr out = 
> avro::memoryOutputStream(CHUNK_SIZE);
> avro::EncoderPtr e = avro::jsonEncoder(cpxSchema);
> e->init(*out);
> c::cpx c1;
> c1.re = 100.23;
> c1.im = 105.77;
> avro::encode(*e, c1);
> out->flush();
> std::cout << "out->byteCount(): " << out->byteCount() << std::endl;
> std::auto_ptr in = avro::memoryInputStream(*out);
> avro::StreamReader streamReader(*in);
> uint8_t jsonBytes[CHUNK_SIZE];
> size_t length = CHUNK_SIZE;
> streamReader.readBytes(jsonBytes, length);
> std::cout << "in->byteCount(): " << in->byteCount() << std::endl;
> std::cout << "result: \'" << jsonBytes << "\'" << std::endl;
> for (size_t i = 0; i < 30; i += 1) {
> printf("jsonBytes[%02zu]: 0x%02X (%c)\n", i, (unsigned char) 
> jsonBytes[i], jsonBytes[i]);
> }
> return 0;
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)