Start Validating json

Validating json

For example, in our projects, we allow the admin/developer to specify which database field of a table is used as display field (in links and such). So, we can generate the schema with available fields on project deployment, and then validate the user configuration against his particular database setup.

It also allows us to improve test-driven development of our API.

If you’ve worked on a test-driven Following the four-phase test pattern, the test above executes a request to the current user endpoint and makes some assertions about the structure and content of the expected response.

While this approach has the benefit of ensuring the response object includes the expected values for the specified properties, it is also verbose and cumbersome to maintain.

Wouldn’t it be nice if the test could look more like this?

Composer documentation provides more information, and links to an even more helpful Those files which are for non-technical users, usually rely on even simpler formats like INI and CSV. But before any of that happens, I need to play around with these amazing tools. First of all, we can obviously validate the configuration files.

Here’s a quick first look that I did: This is great. Secondly, we can automatically generate the documentation for the supported configuration options and values.

Perform a Google search and you’ll find many websites that assist in validating JSON. You paste JSON inside the browser, or specify the URL that returns JSON, and click ‘Validate’.