I'm looking to take a protobuf message object and encode it to a string of 
its protobuf JSON representation, and vice versa.
So far I've been just serializing to protobuf binary format with 
*message.WriteTo(...)* or *MessageExtensions.ToByteArray(message)* and then 
using *BinaryToJsonString(...)* or *BinaryToJsonStream(...)*. Just 
wondering if there's a more direct way of doing this, that doesn't involve 
the 2 steps (something similar to the C# API's 
*JsonFormatter.Format(message)*).

Thanks,
Ron


On Monday, November 23, 2015 at 2:50:19 PM UTC+2, Jon Skeet wrote:
>
> I'm afraid I know nothing about the most appropriate way of doing JSON 
> serialization in the C++ code. It would probably be worth specifying 
> exactly what you're trying to do - do you have a message and want to 
> serialize it straight to a stream, or do you want to get the JSON as a 
> std::string or similar?
>
> Jon
>
>
> On Monday, 23 November 2015 09:25:02 UTC, Ron wrote:
>>
>> Thanks Jon!
>> The wrapper around C++ for JSON deserialization seems to be working well 
>> so far, but since you say C# JSON deserialization has been implemented in 
>> the latest release I'll probably start using that in the near future.
>>
>>
>> Any advice regarding C++? Anyone has suggestions for JSON serialization 
>> and deserialization? Is the proper way going through binary and using the 
>> BinaryToJson/JsonToBinary functions? Or is there a more direct way?
>>
>> Thanks,
>> Ron
>>
>>
>>
>> On Thursday, November 12, 2015 at 3:24:43 PM UTC+2, Jon Skeet wrote:
>>>
>>> C# JSON parsing went in a few days ago, actually. There may still be 
>>> some discrepancies in terms of parsing JSON from third-party sources, but 
>>> I'd expect parsing the JSON output of the C++ protobuf library to work. If 
>>> it doesn't, please let me know!
>>>
>>> The one bit that *isn't* implemented (in either formatting or parsing) 
>>> is the Any well-known type. That's the last big feature on my list, I 
>>> believe.
>>>
>>> Jon
>>>
>>>
>>> On Thursday, 12 November 2015 00:42:22 UTC, Ron wrote:
>>>>
>>>> So far I've been using the binary wire format, and now I'm trying to 
>>>> use JSON serialization for some things and the usage seems to be somewhat 
>>>> different, so looking for a little guidance.
>>>>
>>>> In C++, what are the possible ways to go about JSON serialization and 
>>>> deserialization? So far I could only find ways that use the binary wire 
>>>> format as some sort of an intermediate stage between the JSON 
>>>> representation and C++ message objects. Are there any ways of doing this 
>>>> that are more direct, not going through the binary wire format in between? 
>>>> Also, are there any documents and/or examples for using ObjectWriter and 
>>>> other proto3 classes or are they only going to be available once the final 
>>>> release is out? (I saw a post here mentioning it's likely to be sometime 
>>>> around Q4, is that still the case?)
>>>>
>>>> In C# as far as I can tell serialization can be performed using 
>>>> JsonFormatter directly or through ToString() and deserialization is not 
>>>> implemented yet. Is that correct? Will JSON deserialization be available 
>>>> in 
>>>> the final release? For now I'm using a managed wrapper around the C++ 
>>>> JsonToBinary() function as a temporary solution for C# JSON 
>>>> deserialization 
>>>> and it seems to be working okay. Are there any potential pitfalls with 
>>>> this 
>>>> approach I might be overlooking? Are there any alternatives for the time 
>>>> being?
>>>>
>>>> Thanks in advance,
>>>> Ron 
>>>>
>>>>
>>>>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to