简体   繁体   中英

What is the best practice of testing JSON data?

I'm developing a server-side RESTful application which serves json data for its client applications. And I have to test so many various json outputs. Each json has many properties and their validation methods are different like below a sample json.

So such my use-case, do you know good libraries or web services to test json data flexibly?

{
  "system": { // data structure validation
    "time": 1234566, // data type validation
    "version": "0.0.1" // string matching validation
  },
  "app": { // data structure validation
    "id": "1234", // string matching validation
    "command": "do something", // string matching validation
    "data": { // data structure validation
      "hoge": "xxx", // data type validation
      "fuga": 123 // data type validation
    }
  }
}

What do you mean by validating? validating the JSON structure or the data inside your JSON object? To validate the structure you can parse it to another datatype like dictionary and see if you get any error while. But to validate the data inside the object you need to validate each object in a very specific way for that object.

Use this link Just Place your JSON code and Test it. Quite easy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM