-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON recipe #555
base: master
Are you sure you want to change the base?
JSON recipe #555
Changes from all commits
71fb77a
e8e406f
ace914c
3edbf70
3abeb1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
extern crate skeptic; | ||
|
||
use std::fs; | ||
|
||
fn main() { | ||
skeptic::generate_doc_tests(&["README.md"]); | ||
let paths = fs::read_dir("./pages/").unwrap(); | ||
|
||
for path in paths { | ||
let p = path.unwrap().path(); | ||
let s = p.to_str().unwrap(); | ||
if s.contains(".md") { | ||
skeptic::generate_doc_tests(&[s]) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#JSON | ||
|
||
##JSON implementation in Rust: | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind including a sentence or two about what this recipe demonstrates, please include links to the primary sources of documentation. |
||
|
||
[![json][json-badge]][json] | ||
|
||
```rust | ||
#[macro_use] | ||
extern crate json; | ||
|
||
fn main() { | ||
|
||
let parsed = json::parse(r#" | ||
|
||
{ | ||
"code": 200, | ||
"success": true, | ||
"payload": { | ||
"features": [ | ||
"awesome", | ||
"easyAPI", | ||
"lowLearningCurve" | ||
] | ||
} | ||
} | ||
|
||
"#).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please see proper error handling in cookbook. |
||
|
||
let instantiated = object!{ | ||
"code" => 200, | ||
"success" => true, | ||
"payload" => object!{ | ||
"features" => array![ | ||
"awesome", | ||
"easyAPI", | ||
"lowLearningCurve" | ||
] | ||
} | ||
}; | ||
|
||
assert_eq!(parsed, instantiated); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than comparing the object is equal, please show how to traverse the JSON document to compare individual pieces of data. |
||
|
||
} | ||
``` | ||
# License | ||
|
||
MIT/Apache-2.0 | ||
|
||
<!-- Links --> | ||
[json-badge]: https://img.shields.io/crates/v/rustc-serialize.svg?label=json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the badges are in /src/links.md |
||
[json]: http://json.rs/doc/json/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is meant to resolve some of the errors we are experiencing I'd really appreciate it broken out of the addition of examples