Axel
Axel

Reputation: 5131

Should the server convert incoming data to JSON or client should send data as JSON?

For example, I want to send this data to the server:

{"values": {"key1": "property1", "key2": "property2", "key3": "property3"}}

This values key is supposed to be saved as JSON string in database. Now, where exactly should this JSON be converted?

I mean should I send data from client side as JSON string like {"values": "{\"key1\":\"property1\",\"key2\":\"property2\",\"key3\":\"property3\"}"} or the server should convert it into JSON and save it to the database? Is it somewhat mentioned in REST principles or something?

Upvotes: 0

Views: 205

Answers (1)

Evert
Evert

Reputation: 99717

What format are you wrapping this JSON in? Is it in another JSON object? You might want to consider not doing that and use the 'parent formats' native way to express this object.

The fact that it eventually gets stored as JSON in your database is a detail that your client shouldn't have to care about.

Upvotes: 1

Related Questions