Skip to content

feat: Implement JSON Encoder #11

@zhexuany

Description

@zhexuany

Issue Description

Currently, Robocodec supports reading JSON-encoded messages but does not support writing them. A JSON encoder is useful for:

  • Debugging and inspection
  • Web API integration
  • Human-readable data export
  • Cross-system compatibility

Proposed Solution

Implement a JsonEncoder to complement the existing JsonDecoder.

Requirements

  • Add encoder.rs module in src/encoding/json/
  • Implement MessageCodec trait for JsonEncoder
  • Support encoding from CodecValue to JSON format
  • Handle all primitive types and nested structures
  • Proper array/sequence serialization
  • Handle ROS time types (Time, Duration) correctly
  • Add unit tests for round-trip encoding/decoding
  • Add integration tests
  • Update documentation

Acceptance Criteria

  1. Can encode messages that were previously decoded by JsonDecoder
  2. Round-trip tests pass: decode → encode → decode produces equivalent JSON
  3. Output is valid, readable JSON
  4. Handles complex nested types (sequences, nested messages, time types)

References

  • Existing decoder: src/encoding/json/decoder.rs
  • Codec interface: src/encoding/codec.rs
  • CDR encoder reference: src/encoding/cdr/encoder.rs

Priority: P1 - Core codec completeness
Estimated effort: Low-Medium

Metadata

Metadata

Assignees

No one assigned

    Labels

    encodingRelated to message encoding/decoding (CDR, Protobuf, JSON)priority-P1High priority - core completeness

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions