-
Notifications
You must be signed in to change notification settings - Fork 873
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
ItemUtils in SDK V2 #2628
Comments
We'll take the ask into consideration and reevaluate if we'd like to add support for a ItemUtils equivalent. |
Please bring back the ItemUtils in SDK V2. It's very difficult to work with the dynamodb items without this helper class. |
Please bring this back! |
Hey everyone, this is a Request for Comments: Since ItemUtils.java is fairly extensive utility and there was a change in design from v1 DynamoDB Mapper to v2 DynamoDB Enhanced Client, to help us understand the use cases of a v2 ItemUtils equivalent please comment here which utility methods you'd like it to have, which methods you'd use the most. Be as specific as you can. |
@debora-ito in our case we heavily rely on as an entry point |
To and From conversion between attributeValueMap and regular JSON string: Map<String, AttributeValue> jsonStringToAttrValueMap (String contentJsonString); |
Converting to and from a As an example, we want to be able to pull the raw object out of DynamoDB, run some processing on it, and convert it into a simple map ( Even in the DynamoDB console, there is a direct option to toggle between a simple map and the raw (attribute value) map. I'm not sure why this functionality isnt included in the SDK v2. Like I said in the other thread, it is really a degradation. I'm also a user of the JavaScript SDK v3, what's really needed is a direct equivalent of marshall/unmarshall (same thing as ItemUtils in v1). const { marshall, unmarshall } = require("@aws-sdk/util-dynamodb"); ref: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_util_dynamodb.html |
@debora-ito Any news on this? Are the use cases clear? |
Honestly very surprised they shipped v2 without these Please bring back |
Please bring it back!!! It takes a long time for me to find the utils. What I found is this OPEN issue :( |
It is mind-boggling that a "NoSQL" database in 2022 cannot store and retrieve plain JSON. And that is exactly the case when using DynamoDB with Java and sdk v2. Some of us old-timers know about sdk v1 and ItemUtils, but I expect newer developers will just move on and adopt a competing alternative. |
Pitching my use case if it isn't clearly stated from previous posts. Current API only accepts a It really is a chore to manually write utility classes to handle this. So a native SDK support for |
Hi, curious to know if there were any updates to this? I'm in need of converting attributeValueMap to a regular JSON string 😓 |
How is this still an unresolved issue? Every other language can do this easily. |
Check - #2151 https://www.davidagood.com/dynamodb-enhanced-client-java-heterogeneous-item-collections/ In short:
|
We have added EnhancedDocument which features APIs such as fromJson, fromAttributeValueMap, toJson, and toMap. Aws sdk java 2.x does not have any plans to introduce APIs that lack type safety as compared to ItemUtils. If you come across a use case requiring additional type-safe APIs not already covered in EnhancedDocument, please provide a use case for consideration. |
Closing the issue after monitoring the above comment for 3 months. |
|
I tried using {
"M": {
"MyStringField": { "S": "MyString" }
}
} But was getting the concise JSON, e.g: {
"MyStringField": "MyString"
} I ended up using this. Which is kinda horrible, but gets the json we need and we were only using it in tests so 🤷 It's in Scala, but should be easy to translate to the equivalent Java: Turn AttributeValue val marshaller = JsonProtocolMarshallerBuilder
.create()
.operationInfo(OperationInfo.builder().httpMethod(SdkHttpMethod.PUT).build())
.endpoint(java.net.URI.create("http://dummy"))
.protocolMetadata(
AwsJsonProtocolMetadata.builder().protocol(AwsJsonProtocol.AWS_JSON).build()
)
.jsonGenerator(
AwsStructuredPlainJsonFactory.SDK_JSON_FACTORY.createWriter("application/json")
)
.build()
val request = marshaller.marshall(av)
val bytes = request.contentStreamProvider().get().newStream().readAllBytes();
new String(bytes, StandardCharsets.UTF_8) Parse String val u = JsonProtocolUnmarshaller
.builder()
.defaultTimestampFormats(Map.empty.asJava)
.parser(JsonNodeParser.create())
.build()
val av = AttributeValue.builder()
u.unmarshall(
av,
SdkHttpFullResponse
.builder()
.content(
AbortableInputStream.create(new StringInputStream(jsonString))
)
.build()
)
av.build() |
Please bring back something similar to ItemUtils from sdk v1 to sdk v2. I checked #1975 which was closed due to non-feasibility. But, this would mean all the developers would need to implement the utility independently, which is not ideal. Opening this as feature request again so it can gain attention.
The text was updated successfully, but these errors were encountered: