Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode to a temporary message to extract or change data #260

Open
amyrprv opened this issue Feb 14, 2024 · 1 comment
Open

Decode to a temporary message to extract or change data #260

amyrprv opened this issue Feb 14, 2024 · 1 comment

Comments

@amyrprv
Copy link

amyrprv commented Feb 14, 2024

Hi,
I have the below data for example

{
  "a": {
    "b": "",
    "c": {},
    "d": [
      {
        "e": "",
        "f": "s",
        "g": {
          "h": "",
          "i": "",
          "j": ""
        }
      }
    ],
    "k": {}
  },
  "l": {
    "m": { "t": "u" },
    "n": "v",
    "o": {
      "p": "̊w",
      "q": { "x": 1, "y": 1, "z": 1, "a1": 0 },
      "e": a2
    }
  }
}

Now, I aim to modify the e field within this structure. While I lack the Protobuf definition and message name, I possess the field number path to access e. I plan to generate a temporary message using the provided field numbers, decode the binary, modify the value, and then encode it again.

However, I've encountered an issue: when I decode the modified message alongside the actual message and its definition, I experience data loss and the disappearance of other fields.

Please guide on performing this task without experiencing data loss or losing other fields in the process.

@amyrprv amyrprv closed this as not planned Won't fix, can't repro, duplicate, stale Oct 13, 2024
@amyrprv amyrprv reopened this Oct 13, 2024
@starwing
Copy link
Owner

You could use the lower level API to complete thus mission. See the document of 'Slice' (for decoding) and 'Buffer' (for encoding).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants