File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 4141 </h3 >
4242</div >
4343
44+ ## Examples
45+
46+ Given the following ` .json ` VCR Cassette recording:
47+ ``` json
48+ {
49+ "http_interactions" : [
50+ {
51+ "request" : {
52+ "uri" : " http://localhost:7777/foo" ,
53+ "body" : " " ,
54+ "method" : " get" ,
55+ "headers" : { "Accept-Encoding" : [ " identity" ] }
56+ },
57+ "response" : {
58+ "body" : " Hello foo" ,
59+ "http_version" : " 1.1" ,
60+ "status" : { "code" : 200 , "message" : " OK" },
61+ "headers" : {
62+ "Date" : [ " Thu, 27 Oct 2011 06:16:31 GMT" ],
63+ "Content-Type" : [ " text/html;charset=utf-8" ],
64+ "Content-Length" : [ " 9" ],
65+ }
66+ },
67+ "recorded_at" : " Tue, 01 Nov 2011 04:58:44 GMT"
68+ },
69+ ],
70+ "recorded_with" : " VCR 2.0.0"
71+ }
72+ ```
73+
74+ We can deserialize it using [ ` serde_json ` ] ( https://docs.rs/serde-json ) :
75+
76+ ``` rust
77+ # #![allow(unused)]
78+ use std :: fs;
79+ use vcr_cassette :: Cassette ;
80+
81+ let example = fs :: read_to_string (" tests/fixtures/example.json" ). unwrap ();
82+ let cassette : Cassette = serde_json :: from_str (& example ). unwrap ();
83+ ```
84+
85+ To deserialize ` .yaml ` Cassette files use
86+ [ ` serde_yaml ` ] ( https://docs.rs/serde-yaml ) instead.
87+
4488## Installation
4589``` sh
4690$ cargo add vcr-cassette
You can’t perform that action at this time.
0 commit comments