dtcs 0.1.1

Reference implementation of the Data Transformation Contract Standard (DTCS)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! JSON parser.

use crate::model::TransformationContract;
use crate::parser::{failure, success, ParseResult};

/// Parse a DTCS document from JSON.
#[must_use]
pub fn parse_json(content: &[u8]) -> ParseResult {
    match serde_json::from_slice::<TransformationContract>(content) {
        Ok(contract) => success(contract),
        Err(error) => failure(error.to_string()),
    }
}