Closed nathannaveen closed 3 months ago
Hi @nathannaveen,
Thanks for reaching out. The DynamoDB marshaller (dynamodbattribute.MarshalMap) is designed to convert Go data types into DynamoDB AttributeValue types while preserving the original structure. Modifying it to 'flatten' nested maps would fundamentally alter its purpose and break the expected relationship between Go structs and DynamoDB items.
The current marshaller's implementation maintains the nested structure of the map, which is how DynamoDB expects to store and retrieve complex objects. If you need a flattened structure for your specific use case, that transformation should be handled separately in your application logic.
Thanks, Ran~
Ok, thank you for the help @RanVaknin!
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
Acknowledgements
go get -u github.com/aws/aws-sdk-go-v2/...
)Describe the bug
We need a way to convert an a raw json to an object like this
[]map[string]types.attributevalue
using theattributevalue
package.I am trying to use
dynamodbattribute.MarshalMap
to accomplish this. But, when I do this, the maps aren't flattened, and our usage requires the maps flattened because we're querying dynamo using a step function and passing the results into a lambda.Here is an example:
Is there already way to flatten out the maps? Or is there a work around for this?
Expected Behavior
We would like the maps to be flattened out because we're querying dynamo using a step function and passing the results into a lambda.
Current Behavior
dynamodbattribute.MarshalMap
outputs maps that aren't flattened.Reproduction Steps
Here's an example:
Possible Solution
No response
Additional Information/Context
No response
AWS Go SDK V2 Module Versions Used
github.com/aws/aws-sdk-go-v2 v1.30.3 github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue v1.14.10
Compiler and Version used
go version go1.22.4 darwin/arm64
Operating System and version
macOS Sonoma Version 14.4