Skip to content

Commit 96f09cc

Browse files
committed
Added example of reading JSON from a file, parsing it into a struct, and printing out some parts
1 parent 668609d commit 96f09cc

File tree

5 files changed

+404
-0
lines changed

5 files changed

+404
-0
lines changed

rust/dynamodb/Cargo.lock

Lines changed: 197 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/dynamodb/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "cross-service-code-examples"
3+
version = "0.1.0"
4+
authors = ["Doug Schwartz <dougsch@amazon.com>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
serde = { version = "1.0", features = ["derive"] }
11+
serde_json = "1"
12+
structopt = { version = "0.3", default-features = false }

rust/dynamodb/event1.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"Records": [
3+
{
4+
"eventID": "7de3041dd709b024af6f29e4fa13d34c",
5+
"eventName": "INSERT",
6+
"eventVersion": "1.1",
7+
"eventSource": "aws:dynamodb",
8+
"awsRegion": "region",
9+
"dynamodb": {
10+
"ApproximateCreationDateTime": 1479499740,
11+
"Keys": {
12+
"Timestamp": {
13+
"S": "2016-11-18:12:09:36"
14+
},
15+
"Username": {
16+
"S": "John Doe"
17+
}
18+
},
19+
"NewImage": {
20+
"Timestamp": {
21+
"S": "2016-11-18:12:09:36"
22+
},
23+
"Message": {
24+
"S": "This is a bark from the Woofer social network"
25+
},
26+
"Username": {
27+
"S": "John Doe"
28+
}
29+
},
30+
"SequenceNumber": "13021600000000001596893679",
31+
"SizeBytes": 112,
32+
"StreamViewType": "NEW_IMAGE"
33+
},
34+
"eventSourceARN": "arn:aws:dynamodb:region:123456789012:table/BarkTable/stream/2016-11-16T20:42:48.104"
35+
}
36+
]
37+
}

rust/dynamodb/event2.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"Records": [
3+
{
4+
"eventID": "7de3041dd709b024af6f29e4fa13d34c",
5+
"eventName": "INSERT",
6+
"eventVersion": "1.1",
7+
"eventSource": "aws:dynamodb",
8+
"awsRegion": "us-west-2",
9+
"dynamodb": {
10+
"ApproximateCreationDateTime": 1479499740,
11+
"Keys": {
12+
"Timestamp": {
13+
"S": "2021-2-18:12:09:36"
14+
},
15+
"Username": {
16+
"S": "John Dough"
17+
}
18+
},
19+
"NewImage": {
20+
"Timestamp": {
21+
"S": "2021-2-18:12:09:36"
22+
},
23+
"Message": {
24+
"S": "This is a message, doh!"
25+
},
26+
"Username": {
27+
"S": "John Dough"
28+
}
29+
},
30+
"SequenceNumber": "13021600000000001596893679",
31+
"SizeBytes": 112,
32+
"StreamViewType": "NEW_IMAGE"
33+
},
34+
"eventSourceARN": "arn:aws:dynamodb:region:123456789012:table/BarkTable/stream/2016-11-16T20:42:48.104"
35+
}
36+
]
37+
}

0 commit comments

Comments
 (0)