You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 14_json_serialization.md
+5-7
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ This will print the following:
65
65
66
66
This is the [JSON](https://www.json.org/json-en.html) format, a human-readable data-interchange format that transmits data objects consisting of key-value pairs and arrays.
67
67
68
-
In Rust, there is a popular crate available for taking some data and converting it into or "**serializing**" it in the JSON format.
68
+
In Rust, there is a popular crate available for taking some data and converting it (or "**serializing**" it) into the JSON format.
69
69
We can use the [`serde_json`](https://docs.rs/serde_json/latest/serde_json/) crate for this.
70
70
71
71
Let's add this to our Cargo.toml file.
@@ -94,7 +94,7 @@ This will work as long as all of the primitive types it contains can be serializ
94
94
Finally, we'll call `to_string()` method on `serde_json` to convert inputs into a JSON formatted string.
95
95
Let's try that and see what happens.
96
96
97
-
*Reminder: We don't need to import top-level modules such as `serde_json` as those will already be included by default in our `main.rs` file.*
97
+
*Note: We don't need to import top-level modules such as `serde_json` as those will already be included by default in our `main.rs` file.*
Ok, that's way better! Starting to look much more similar to the output from `bitcoin-cli`.
216
215
217
-
Let's make one more modification to place all the different pieces of a transaction, such as the version, inputs and outputs all into one `Transaction` struct.
218
-
219
-
We'll add the `Transaction` struct:
216
+
Let's make one more modification to place all the different pieces of a transaction, such as the version, inputs and outputs all into a `Transaction` struct.
217
+
First, declare the `Transaction` struct:
220
218
```rust
221
219
#[derive(Debug, Serialize)]
222
220
structTransaction {
@@ -258,7 +256,7 @@ fn main() {
258
256
}
259
257
```
260
258
261
-
And now we should see an output with everything neatly printed out under one `Transaction` JSON object!
259
+
Now we should see an output with everything neatly printed out under one `Transaction` JSON object!
0 commit comments