Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A Java library that allows for verbose JSON structure and content verification, ideally for use in unit testing and end to end functional verification of applications that utilize JSON as a means of communicating serialized data

License

Notifications You must be signed in to change notification settings

Gnof/JsonValidator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Validator v1.0

This is a Utility library meant to make JSON operations, particularly 
comparison of deserialized complex objects easier.
  
Doing a comparison in complex JSON objects has been tedious because it's
either too strict a comparison (straight string comparison) or not strict
enough (random false positives).
  
Here's an example of something we've run into for automated verification:
  
{value1: [{status:false},{cause:service}],
 value2:[{status:true},{cause:device}]} 
 
   
The goal is to have as flexible a way to verify that this data is there
without having to completely reproducing the data in a verification input.
  
The input for the verifier, in order to provide flexibility and verbosity
needed to convey the verification constraints will be accepted as a JSON
string.
  
The following (JSON) format will define what is needed: 
 
[ 
	{
  		attribute:(required)'name of attribute to verify',
  		value:(optional, default:none)'a (string representation) value or list 
  				of values if multiples of this attribute are expected', 
  		quantity:(optional, default: 1)'number of times we expect to see this 
  				attribute',
  		composite:(optional, default: none)'a list of composite identifiers 
  				to search for that are in the scope of this specific 
  				object',
  		hierarchy:(optional, default: none)'a comprehensive hierarchy that 
  				leads to the attribute, in order from the root to the 
  				attribute', 
  		ancestor:(optional, default: none)'an expected ancestor (or ancestors) 
  				belongs to this attribute'
  	} 
]
  
-- Since JSON keys within an object are meant to be unique, quantity
represents the number of attributes within a whole JSON. 
i.e. 
for the following validation: 

{'attribute':'minor-attribute', quantity:3}

--The target JSON--
{mainAttribute:
	[
		{minor-attribute: val1}, 
		{minor-attribute: val2}, 
		{minor-attribute: val3}
	]
}

would pass.  
 
For a detailed explanation of each verification type and examples of how they can be used,
please see the [wiki](https://github.com/Gnof/JsonValidator/wiki).

About

A Java library that allows for verbose JSON structure and content verification, ideally for use in unit testing and end to end functional verification of applications that utilize JSON as a means of communicating serialized data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages