Re: [protobuf] Deserializing of protobf Message from JSON string in C++

2017-10-25 Thread 'Feng Xiao' via Protocol Buffers
On Wed, Oct 25, 2017 at 1:46 AM, Giri Guntipalli 
wrote:

> I am also facing similar issue but problem seems to happen only when
> library is complied with -O2 or –Os(optimize for size)  with gcc tool chain.
>
>
>
> looks like extensions are being treated as dead code and removed by gcc
> optimization, any thoughts on overcoming this problem.
>
The extension has to be explicitly referenced or the linker will strip them
out.


>
>
> Thank you
>
> Giri
> On Thursday, 6 June 2013 00:15:14 UTC+5:30, Feng Xiao wrote:
>>
>>
>>
>>
>> On Wed, Jun 5, 2013 at 2:44 AM, Channakeshava S C 
>> wrote:
>>
>>> I am facing problem in getting protobuf Message with extension from JSON
>>> string  {"xyz": [1234,2345,3456],"extensions":{"bar": [1,11,111]}}
>>> which is generated from Foo.
>>>
>>> message Foo {
>>>  repeated int32 xyz = 11;
>>>  extensions 100 to 199;
>>> }
>>>
>>> extend Foo {
>>>  repeated int32 bar = 123;
>>> }
>>>
>>> The word "extensions" in the JSON stirng is just added to differentiate
>>> with other normal fileds.
>>>
>>> Now, when I try to deserialize protobuf, i.e protobuf Message from JSON
>>> string. Facing difficulty here.
>>>
>>> fd is NULL, when FindExtensionByName or FindKnownExtensionByName is
>>> called .
>>>
>>> Foo foo;
>>> Message *x = 
>>> const FiledDescriptor *fd;
>>>
>>> fd = x->GetDescriptor()->FindExtensionByName("bar")or
>>> fd = x->GetReflection()->FindKnownExtensionByName("bar");
>>>
>> Is the extension defined in the same .proto file with the message?  The
>> second one should work.
>>
>>
>>>
>>> Could you point out any error in steps which I am following or Is there
>>> any other better approach?
>>>
>>>
>>> Thanks,
>>> Channakeshava
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Protocol Buffers" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to protobuf+u...@googlegroups.com.
>>> To post to this group, send email to prot...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/protobuf?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] Deserializing of protobf Message from JSON string in C++

2017-10-25 Thread Giri Guntipalli


I am also facing similar issue but problem seems to happen only when 
library is complied with -O2 or –Os(optimize for size)  with gcc tool chain.

 

looks like extensions are being treated as dead code and removed by gcc 
optimization, any thoughts on overcoming this problem.

 

Thank you

Giri
On Thursday, 6 June 2013 00:15:14 UTC+5:30, Feng Xiao wrote:
>
>
>
>
> On Wed, Jun 5, 2013 at 2:44 AM, Channakeshava S C  > wrote:
>
>> I am facing problem in getting protobuf Message with extension from JSON 
>> string  {"xyz": [1234,2345,3456],"extensions":{"bar": [1,11,111]}} which is 
>> generated from Foo.
>>  
>> message Foo {
>>  repeated int32 xyz = 11;
>>  extensions 100 to 199; 
>> }
>>  
>> extend Foo {
>>  repeated int32 bar = 123;
>> }
>>  
>> The word "extensions" in the JSON stirng is just added to differentiate 
>> with other normal fileds.
>>  
>> Now, when I try to deserialize protobuf, i.e protobuf Message from JSON 
>> string. Facing difficulty here.
>>  
>> fd is NULL, when FindExtensionByName or FindKnownExtensionByName is 
>> called .
>>  
>> Foo foo;
>> Message *x =  
>> const FiledDescriptor *fd;
>>  
>> fd = x->GetDescriptor()->FindExtensionByName("bar")or 
>> fd = x->GetReflection()->FindKnownExtensionByName("bar");
>>
> Is the extension defined in the same .proto file with the message?  The 
> second one should work.
>  
>
>>
>> Could you point out any error in steps which I am following or Is there 
>> any other better approach?
>>  
>>  
>> Thanks,
>> Channakeshava
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Protocol Buffers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to protobuf+u...@googlegroups.com .
>> To post to this group, send email to prot...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/protobuf?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Deserializing of protobf Message from JSON string in C++

2013-06-05 Thread Channakeshava S C
I am facing problem in getting protobuf Message with extension from JSON 
string  {xyz: [1234,2345,3456],extensions:{bar: [1,11,111]}} which is 
generated from Foo.
 
message Foo {
 repeated int32 xyz = 11;
 extensions 100 to 199; 
}
 
extend Foo {
 repeated int32 bar = 123;
}
 
The word extensions in the JSON stirng is just added to differentiate 
with other normal fileds.
 
Now, when I try to deserialize protobuf, i.e protobuf Message from JSON 
string. Facing difficulty here.
 
fd is NULL, when FindExtensionByName or FindKnownExtensionByName is called .
 
Foo foo;
Message *x = foo; 
const FiledDescriptor *fd;
 
fd = x-GetDescriptor()-FindExtensionByName(bar)or 
fd = x-GetReflection()-FindKnownExtensionByName(bar);

Could you point out any error in steps which I am following or Is there any 
other better approach?
 
 
Thanks,
Channakeshava

-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [protobuf] Deserializing of protobf Message from JSON string in C++

2013-06-05 Thread Feng Xiao
On Wed, Jun 5, 2013 at 2:44 AM, Channakeshava S C 
channakeshava...@gmail.com wrote:

 I am facing problem in getting protobuf Message with extension from JSON
 string  {xyz: [1234,2345,3456],extensions:{bar: [1,11,111]}} which is
 generated from Foo.

 message Foo {
  repeated int32 xyz = 11;
  extensions 100 to 199;
 }

 extend Foo {
  repeated int32 bar = 123;
 }

 The word extensions in the JSON stirng is just added to differentiate
 with other normal fileds.

 Now, when I try to deserialize protobuf, i.e protobuf Message from JSON
 string. Facing difficulty here.

 fd is NULL, when FindExtensionByName or FindKnownExtensionByName is called
 .

 Foo foo;
 Message *x = foo;
 const FiledDescriptor *fd;

 fd = x-GetDescriptor()-FindExtensionByName(bar)or
 fd = x-GetReflection()-FindKnownExtensionByName(bar);

Is the extension defined in the same .proto file with the message?  The
second one should work.



 Could you point out any error in steps which I am following or Is there
 any other better approach?


 Thanks,
 Channakeshava

 --
 You received this message because you are subscribed to the Google Groups
 Protocol Buffers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to protobuf+unsubscr...@googlegroups.com.
 To post to this group, send email to protobuf@googlegroups.com.
 Visit this group at http://groups.google.com/group/protobuf?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [protobuf] Deserializing of protobf Message from JSON string in C++

2013-06-05 Thread Channakeshava S C
Thanks for the reply.
 
Yes, the extension defined in tha same .proto file.
 
 fd = x-GetReflection()-FindKnownExtensionByName(bar); this is 
returning fd as NULL.
 
 
foo.SetExtension(bar, xyzValue); and foo.AddExtension(bar, xyzValue); are 
possible when we invoke on foo variable.

But why same functions are not visible on x(instance of protobuf Message) ?
How to fill values to extended feilds in Message?
 
 

On Thursday, June 6, 2013 12:15:14 AM UTC+5:30, Feng Xiao wrote:




 On Wed, Jun 5, 2013 at 2:44 AM, Channakeshava S C 
 channake...@gmail.comjavascript:
  wrote:

 I am facing problem in getting protobuf Message with extension from JSON 
 string  {xyz: [1234,2345,3456],extensions:{bar: [1,11,111]}} which is 
 generated from Foo.
  
 message Foo {
  repeated int32 xyz = 11;
  extensions 100 to 199; 
 }
  
 extend Foo {
  repeated int32 bar = 123;
 }
  
 The word extensions in the JSON stirng is just added to differentiate 
 with other normal fileds.
  
 Now, when I try to deserialize protobuf, i.e protobuf Message from JSON 
 string. Facing difficulty here.
  
 fd is NULL, when FindExtensionByName or FindKnownExtensionByName is 
 called .
  
 Foo foo;
 Message *x = foo; 
 const FiledDescriptor *fd;
  
 fd = x-GetDescriptor()-FindExtensionByName(bar)or 
 fd = x-GetReflection()-FindKnownExtensionByName(bar);

 Is the extension defined in the same .proto file with the message?  The 
 second one should work.
  


 Could you point out any error in steps which I am following or Is there 
 any other better approach?
  
  
 Thanks,
 Channakeshava

 -- 
 You received this message because you are subscribed to the Google Groups 
 Protocol Buffers group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to protobuf+u...@googlegroups.com javascript:.
 To post to this group, send email to prot...@googlegroups.comjavascript:
 .
 Visit this group at http://groups.google.com/group/protobuf?hl=en.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  




-- 
You received this message because you are subscribed to the Google Groups 
Protocol Buffers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.