Hello,

I have a protobuf like this in a ByteString variable 'cp':

1: {
1: 30
2: {
2: 100
}
}
   
   
And I also have another ByteString 'hotel' with this content:

     1: 87354
     2: {
(...) a lot of content here
     }

 
Now I need:

1. Put the 'hotel' ByteString under a "Hotels" tag with key = 2:

2: {
 1: 87354
 2: {
(...) a lot of content here
 }
}
  
  
2. And finally "concat" these two ByetString 'cp' and 'hotels' and put them 
under another tag "Success" with key = "1":

1: {
1: {
1: 30
2: {
2: 100
} 
}
2: {
1: 87354
2: {
(...) a lot of content here
}
}
}

I have solved this and it's working. What I did:

// Add hotel under '2' (hotels) and "concat" cp + hotels
UnknownFieldSet.Builder b2 = 
UnknownFieldSet.newBuilder().mergeFrom(cp).mergeLengthDelimitedField(2, 
hotel);

// Add 'b2' to '1' ('Success')
UnknownFieldSet.Builder b1 = 
UnknownFieldSet.newBuilder().mergeLengthDelimitedField(1, 
b2.build().toByteString());


But since I'm a newbie in protobuf, I would like to know if my solution is 
the optimal or there is a better way to solve this.

Any suggestion would be really appreciated.

Thanks,

Joan.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/707ed7d8-5718-4034-a5dc-503baf1ff126n%40googlegroups.com.

Reply via email to