Skip to content

Add support for Redis JSON#3390

Open
Dgramada wants to merge 8 commits into
spring-projects:mainfrom
Dgramada:feature/json-integration
Open

Add support for Redis JSON#3390
Dgramada wants to merge 8 commits into
spring-projects:mainfrom
Dgramada:feature/json-integration

Conversation

@Dgramada

@Dgramada Dgramada commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

This is a follow up pull request to #3327 that handles the new JSON API for Spring Data Redis.
It builds upon the command layer from the referenced PR and adds API for the template layer.

Notes:

  • BoundJsonOperations is not included yet. Once a version of JsonOperations is approved, the bound operations can be included in this branch.
  • RedisJsonTemplate initially felt like a good idea. It creates a separation of concerns, which is nice because the new JSON API does not pair well with a specific V type unlike the other data types in RedisTemplate. However, RedisJsonTemplate feels a little off and maybe a more elegant solution could be derived. It feels more like a configuration class. Maybe we could rename it to RedisJsonConfig. This would also promote developers to inject JsonOperations directly.
  • RedisJsonSerializer does not extend RedisSerializer, due to it bringing a lot of functionality that doesn't add any value to the JSON serialization. Furthermore, keeping them separate gives separation of concerns. Also Jedis and Lettuce do not provide byte[] APIs for the JSON commands in Redis, thus making RedisSerializer incompatible.

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

Dgramada added 2 commits June 23, 2026 12:35
Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 29, 2026
Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
@Dgramada Dgramada marked this pull request as ready for review June 30, 2026 11:43
Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
@mp911de mp911de changed the title Feature/json integration Add support for Redis JSON Jul 1, 2026
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 1, 2026

@mp911de mp911de left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's an initial round of review feedback.

Comment thread src/main/java/org/springframework/data/redis/connection/json/JsonPath.java Outdated
Comment thread src/main/java/org/springframework/data/redis/core/JsonOperations.java Outdated
Comment thread src/main/java/org/springframework/data/redis/core/RedisJsonTemplate.java Outdated
super.afterPropertiesSet();

if (keySerializer == null) {
keySerializer = (RedisSerializer<K>) new JdkSerializationRedisSerializer(classLoader != null ? classLoader : this.getClass().getClassLoader());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's default to String serializers. Zooming out, a constructor RedisJsonTemplate(RedisConnectionFactory) with String and a default JSON serializer(Jackson 2/Jackson 3) makes sense. Also, a constructorRedisJsonTemplate(RedisConnectionFactory, RedisSerializer, RedisJsonSerializer)` as alternative to provide serializers.

Moving off mutable state is a good thing. We can still keep transaction support but even for transactions I am not sure we should do this.

@viktoriya-kutsarova viktoriya-kutsarova Jul 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussing with @mp911de and @Dgramada, we agreed to mark transaction support as out of scope for this feature. @Dgramada will remove the related code.

We also agreed that RedisJsonTemplate should default to a string serializer for keys and RedisJsonSerializer for values (the actual JSON). @Dgramada explored the proposed constructor approach, but it led to this line:

this.keySerializer = (RedisSerializer<K>) RedisSerializer.string();

which would break if K is anything other than String. Following @mp911de's suggestion, we'll explore a static factory method next and see whether it surfaces any other issues.

Comment thread src/main/java/org/springframework/data/redis/core/RedisJsonTemplate.java Outdated
Comment thread src/main/java/org/springframework/data/redis/serializer/RedisJsonSerializer.java Outdated
Dgramada added 4 commits July 8, 2026 16:19
Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
Signed-off-by: Yordan Tsintsov <yordan.tsintsov@redis.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants