Now there are a lot of tools on the site to deal with JSON format, but I looked for a day, found that most of the need to write the corresponding object class to deal with, more trouble, such as: Gson,json-lib. Gson,json-lib these parameters, such as interfaces, have a fixed number of names and numbers of JSON format that is a lever, not to say. But what I want to do is to deal with the test data file, test data file is the parameter name, the number is not fixed, and I wrote groovy script can only be a file, if use Gosn, and so on, each test file must write an internal class, trouble not to say, reusability is still low.
Finally, it is found that there is a tool class to handle this parameter number or the name is not fixed string super simple, just one method. This is the tool class:Net.sourceforge.plastosome.json.JSON.
The method is json.deserialize (Reader reader).
The subclass of reader is for string type and file, so there is no problem at all. Whether you want to handle [{},{}] or [{}] or [{{}} {{}}] can be resolved successfully. If there is only one JSON in [], then the method return value is a hashmap, and if there is more than one JSON in [], the return value is ArrayList. This is what you can see with the GetClass () method.
Ultra-simple string handling in JSON format and JSON array format