Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

267
Vistas
gRPC: Unknown JSON as input and output

I'm new to gRPC, I'm trying to expose gRPC server in which and rpc does not have known shape before hand.

Requirement is that particular field can have any value present in it.

Ex: file.proto

syntax = "proto3";

import "google/protobuf/struct.proto";

string corr_id = 1;
google.protobuf.Struct message = 2;

When i went through the docs there is no way we can create gRPC server without knowing the fields before hand. For this struct to work, i'm doing the following conversion and making it work.

Actual JSON Object:

{
  name: "wer",
  age: 28,
  hobbies: ["Cricket", "Tea"],
  key: {
     value1: 89,
     value2: "sure next"
  }
}

gRPC Server Requires this below conversion:

{
  "fields": {
    "name": {
      "stringValue": "wer"
    },
    "age": {
      "numberValue": 28
    },
    "hobbies": {
      "listValue": {
        "fields": [
          "Cricket",
          "Tea"
        ]
      }
    },
    "key": {
      "structValue": {
        "fields": {
          "value1": {
            "numberValue": 89
          },
          "value2": {
            "stringValue": "sure next"
          }
        }
      }
    }
  }
}

Is there util available already to do this conversion ? OR is there any other way i can achieve this without the conversion to make gRPC server parse the request ?

Imagine what i have to do for the below json ?

{
    name: "Sathish",
    age: 28,
    address: [
      {
        is_primary: true,
        name: "address1"
      },
      {
        is_primary: false,
        name: "address2"
      }
    ],
    hobbies: ["Cricket", "Tea"],
    movies: {
      liked: ["Re"],
      unliked: ["Te"]
    },
    key: {
      value1: 89,
      value2: "sure next"
    }
  }

Note: I'm using @grpc/grpc-js package alone for now.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda