Skip to content

Topics for the JSON chapter #86

@japaric

Description

@japaric

This is what I have in mind at the moment (but we should try to reduce the number of topics by merging some of them)

  • Custom Encoding/Decoding (to Structs)
  • Decoding from &str
  • Default Decoding/Encoding #[deriving(Encodable,Decodable)]
  • Encoding to String
  • Error handling (DecoderError, ParserError, etc)
  • Streaming (which is not documented)
  • The Json intermediate struct
  • ToJson
  • How JSON types match to Rust types: null <-> None, [] <-> Vec, "" <-> String, Object <-> TreeMap<String, T>/HashMap<String, T>

Feedback is welcome!

Order-wise, this chapter should be after the "hashmap"/"treemap" chapters.

The structure of the chapter should look like this (some topics are still missing):

.
|-- `Json` -> The `Json` enum and its variants
|   |-- Decoding -> `json::from_str` + `BuilderError`
|   |-- `ToJson`` -> struct -> `Json`
|   `-- Stringify??? -> `Json` -> `String`
|-- `Decoder` -> `Json` -> `Decoder` -> `T` - where `T` = `Vec`, `String`, `HashMap`, etc
|-- `Decodable` -> `#[deriving(Decodable)]`
|   `-- Custom??? -> Manually implement `Decodable`
`-- `Encodable` -> `#[deriving(Encodable)]`, `str_encode`
    `-- Custom??? -> Manually implement `Encodable`

@vojtechkral is working on this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions