-
Notifications
You must be signed in to change notification settings - Fork 30
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
Deserialize DDB item from JSON #24
Comments
My current working plan is to add support in |
Since You shouldn't have to handle the AWS's special serialization of DynamoDb values {
"prop1": {
"S": "value1"
},
"prop2": {
"S": "value2"
}
} It looks like aws_lambda_events is already handling that part. |
As a first attempt, I added support for However, implementing the |
The implementation is here, mbergkvist#1 |
Related: awslabs/aws-sdk-rust#497 |
Any suggestions for how we can get mbergkvist#1 over the finish line? This PR would be super useful. |
version 4.0.0 was released this morning with support for 4.0.0 doesn't implement deserializing from an item in JSON format, but does the 4.0.0 release fulfill your needs? |
@bryanburgers yes it looks like 4.0.0 supports my needs, thank you very much! Could you elaborate on that JSON deserialization being missing though? |
@indiv0, yeah, by that I just mean that {
"prop1": {
"S": "value1"
},
"prop2": {
"S": "value2"
}
} into an AttributeValue. That's not a change in 4.0.0; it has never done that part of the deserialization. That part of the deserialization has always been handled by aws-sdk-dynamodb, rusoto_dynamodb, and aws_lambda_events. |
Thanks for the support! |
Seriously though, it shouldn't be so hard to map JSON to I tracked down the generated code in the AWS SDK that does it: However, that code isn't exported, so no way to use it. :/ (Would be awesome if the SDK's Anyway, I really like serde_dynamo. Would you be open to adding support (accepting a PR) for JSON? Could come in the form of a simple helper function similar to the linked code. I know it's not the primary goal of this project. Let me know what you think. |
That's exactly what Rusoto does btw: https://rusoto.github.io/rusoto/src/rusoto_dynamodb/generated.rs.html#40-91 |
@mlafeldt If this code was added to this project, how would you use it? You've basically make two assertions here:
I agree with both. (That argument also applies to a lot of other things that haven't been added: an But unless the code adds tangible value to the project, then adding this code is adding to the maintenance of the code without adding value, and that's a net loss. Right now, my understanding is that the only way this library gets used is:
Do you have a different use for this library? I'm certainly not saying no. I've gone back and forth on adding this a couple of times. What I am saying is that I'd like to understand the real world use-cases first, and go from there. |
Hey @bryanburgers, I agree with your points, esp. the one on maintainability. I did a bit more digging and the situation with serde and aws-sdk-rust seems, well, complicated. In the meantime, I was able to marshall/unmarshall DynamoDB items to and from JSON by piecing together code from Rusoto and serde_dynamo. (My original use case involved using serde_dynamo to turn items from the SDK into |
@bryanburgers I came here looking for the same thing, my use case is different, however. I'm using a sort key to serialize a bunch of information about the item stored in my table, I have a parser written in rust that deserializes that information into fields on a struct. I am now trying to share that parser code with a node application that uses the same table and has its own much slower, much more fragile parser implementation. The AWS dynamodb sdk isn't usable within WASM, so I'm using the node SDK to fetch my items as JSON. I want to pass the JSON across the WASM boundary to do the conversion into my domain object. |
Oooh, that’s a fantastic use case. |
I started writing a separate crate with an entire json parser/deserializer for the dynamodb attributevalue format, but perhaps you have a better idea? |
@bryanburgers can we reopen this issue, or would you like me to open a new one |
Anyone who's still interested in this issue: I just pushed a branch up, and I'd be curious if you could use that branch and see if it works for you? |
Can i use
serde_dynamo
to deserialize an item in JSON to a struct. Something liketo
The reason I'm asking is that I'm trying to deserialize the
newItem
andoldItem
in a DDB Stream event.The text was updated successfully, but these errors were encountered: