Expand description
Reads and writes the JSON AST representation described in the specification.
As that there is no separate model-level namespace, all shape names have been made absolute in this representation. This is a problem when constructing the model, if there are shapes from different namespaces present the parser will return an error at this time.
§Example
The following JSON demonstrates the structure of the AST format.
{
"smithy": "1.0",
"metadata": {
"authors": [
"Simon"
]
},
"shapes": {
"smithy.example#MyString": {
"type": "string",
"traits": {
"smithy.api#documentation": "My documentation string",
"smithy.api#tags": [
"a",
"b"
]
}
},
"smithy.example#MyList": {
"type": "list",
"member": {
"target": "smithy.api#String"
}
},
"smithy.example#MyStructure": {
"type": "structure",
"members": {
"stringMember": {
"target": "smithy.api#String",
"traits": {
"smithy.api#required": {}
}
},
"numberMember": {
"target": "smithy.api#Integer"
}
}
}
}
}The following will parse the model above.
use atelier_core::io::read_model_from_string;
use atelier_json::JsonReader;
let mut reader = JsonReader::default();
let result = read_model_from_string(&mut reader, JSON);
if result.is_err() {
println!("{:?}", result);
}
assert!(result.is_ok());
println!("{:#?}", result.unwrap());Structs§
- Json
Reader - This struct implements the
ModelReadertrait to read a Model from the JSON AST representation. - Json
Writer - This struct implements the
ModelWritertrait to write a Model in the JSON AST representation.
Constants§
- FILE_
EXTENSION - The extension to use when reading from, or writing to, files of this type.
- REPRESENTATION_
NAME - The name to report in errors in this representation.
Functions§
- model_
to_ json - Return a JSON AST representation
of a model. The return value is a [Serde JSON/(https://docs.serde.rs/serde_json/)
Valuethat represents the top-level model.