Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda