Skip to content

Commit

Permalink
update json unit type serde impl to output valid json
Browse files Browse the repository at this point in the history
  • Loading branch information
knickish committed Aug 6, 2023
1 parent 56e28c9 commit 8e8fd5d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/serde_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,15 +748,18 @@ where

impl SerJson for () {
fn ser_json(&self, _d: usize, s: &mut SerJsonState) {
s.out.push_str("")
s.out.push_str("null")
}
}

impl DeJson for () {
fn de_json(s: &mut DeJsonState, i: &mut Chars) -> Result<(), DeJsonErr> {
// skip ""
s.next_tok(i)?;
return Ok(());
if let DeJsonTok::Null = s.tok {
s.next_tok(i)?;
return Ok(());
} else {
return Err(s.err_token("null"));
}
}
}

Expand Down

0 comments on commit 8e8fd5d

Please sign in to comment.