dfinity / dfinity/candid

Add implementation of CandidType for serde_json::Value

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

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
301
Forks
85
Avg merge
1h 4m
Merged PRs (30d)
4

Description

See this forum post for more information: https://forum.dfinity.org/t/derive-candidtype-with-serde-json/5800

Seems it would be nice for candid to implement CandidType on serde_json::Value. This would allow for candid serialization of arbitrary JSON values. I would implement CandidType myself, but in my crates I am depending on serde_json::Value and candid directly, thus I can't implement CandidType without relying on some kind of wrapper around serde_json::Value. Seems serde_json::Value is the canonical way to serialize and deserialize arbitrary JSON in Rust, so could it be added to the library here? https://github.com/dfinity/candid/blob/master/rust/candid/src/types/impls.rs

I am happy to do the work if it would be accepted.

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 with rust/candid/src/types/impls.rs and read the linked forum discussion to understand the intended mapping for serde_json::Value. Compare nearby CandidType implementations and identify the relevant test location. Done means arbitrary JSON values can be serialized through candid without requiring a wrapper type.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend-api-design
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.