Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Doubt on JSON structure - Terrifically Simple JSON

Hi,

In my situation, I am an Enterprise CTO and my 3rd party service provider's JSON API doesn't adhere to Apigee's Best Practices found here:-

1. Apigee's book "Web API: The Missing Link" which gives some guidance and best practices around JSON usage (among other things).

2. @Martin Nally @Martin Nally Martin Nally's https://github.com/mpnally/Terrifically-Simple-JSON

Specifically, I was wondering if I could have your thoughts on the following:-

If an application developer were to make an API call like

GET /Products

and the request payload needed to include say 1 attributes which is

State

I would argue that the cleanest/better JSON structure would be

{

	"State": "New York"

}

as opposed to

{
	"productSegment": {

		"State" : "New York"

	}
}

My argument is that the JSON object itself corresponds to the product segment so there is no need to call it out again unnecessarily complicating the payload. Thoughts ?

I know this sounds like minutiae but it would be nice to have some clarity around how to structure JSON.

Side Question: Is it ok to have a request body in a GET call?

0 4 433
4 REPLIES 4