spring-projects / spring-projects/spring-data-rest

Serializing and Deserializing json in a different format. [DATAREST-614]

Open
#987 3 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

in: content-negotiation status: feedback-provided type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Jack Matthews opened DATAREST-614 and commented

I need to serialize my json in http://jsonapi.org/ instead of HAL. I have tried modifying ObjectMapper by setting my own converters.

	@Bean
	public ConversionService conversionService() {
		ConversionServiceFactoryBean bean = new ConversionServiceFactoryBean();
		bean.setConverters(getConverters());
		bean.afterPropertiesSet();
		ConversionService object = bean.getObject();
		return object;
	}

	private Set<Converter> getConverters() {
		Set<Converter> converters = new HashSet<>();

		converters.add(new JsonApiSerializingConverter());
		converters.add(new JsonApiDeserializingConverter());

		return converters;
	}

but this only modifies the "content" part of the payload. It still includes a whole lot of HAL boilerplate. Is there a way to register a custom json format and scrap the HAL one completely? I am happy to do the work in integrating this format but need some pointers in the best way to approach this


Affects: 2.1.6 (Dijkstra SR6)

1 votes, 3 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.