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

265
Views
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
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!