influxdata / influxdata/pbjson

How to create `pbjson_types::Value` from `serde_json::Value`

Open
#96 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
116
Forks
55
PR merge metrics
No merged PRs in 30d

Description

So I have a `serde_json::Value` and I want to convert it into a `pbjson_types::Value`. I need this because my proto file defines a field with the type `google.protobuf.Value`. I've looked through the source quite a bit and I'm really not sure how to do this. It seems like you can only build `pbjson_types::Value` from either primitive types, other `pbjson_types`, or a serde serializer.

My assumption was I'd be able to call something like `pbjson_types::Value::from(my_value)` and it'd just work if `my_value` implements serde Serialize, but that doesn't seem to be the case. So I've tried to convert it to `serde_json::Value` myself first, but there is still no way to convert from that to `pbjson_types::Value`.

I've read the other issues and some tests in the code but can't figure it out. So any help would be much appreciated.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing pbjson_types::Value constructors and serde serializer implementations mentioned in the issue, then review the related tests. Determine how serde_json::Value is expected to enter this conversion path and document or test the supported behavior; done means the requested conversion is clearly supported or its limitation is explicitly explained.

Written by the indexing model from the issue text.

Assessment

Tech stack
json, rust
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.