Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
Create protobuf with json values

is it possible to merge or set protobuf message values with matching json values???

example json:

{id: 1, channel: 2, userIsLogged:true}

and a proto definition:

message ServerResponse {
    int32 id = 1
    Result result = 2
    int32 channel = 3
    bool userExists = 4
    bool userIsLogged =5
}

Is there a tool or proto utility to create the proto message without setting the properties individually?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It depends on which language you are using with Protobuf message. Protobuf has provides some toolkits to parse Proto3 message from Json.

If you are using Java, you could use JsonFormat to parse Json into Protobuf message:

JsonFormat.parser().merge(json_string, builder);

If you are using C++, you could use json_util to parse Json:

#include <google/protobuf/util/json_util.h>
int main(int argc, char** argv){
  ServerResponse sr
  // Parse the json_string into sr.
  google::protobuf::util::JsonParseOptions options;
  JsonStringToMessage(json_string, &sr, options);
}

For other languages, you could check Protobuf reference to find a related toolkit.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!