Created
          January 23, 2015 16:20 
        
      - 
      
- 
        Save SpringMT/6313458116b73556d417 to your computer and use it in GitHub Desktop. 
    JSON::Validator.validate遅い。。。
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'json' | |
| require 'json-schema' | |
| json_data = [] | |
| 70_000.times do |i| | |
| json_data << {id: i, name: "てすとてすと", point: 20495, description: "しらたま"} | |
| end | |
| json_schema = <<JSON | |
| { | |
| "type": "array", | |
| "items": { | |
| "type": "object", | |
| "required": [ | |
| "id" | |
| ], | |
| "properties": { | |
| "id": { | |
| "type": "integer" | |
| }, | |
| "name": { | |
| "type": "string", | |
| "minLength": 2, | |
| "maxLength": 15 | |
| }, | |
| "point": { | |
| "type": "integer" | |
| }, | |
| "description": { | |
| "type": "string", | |
| "minLength": 2, | |
| "maxLength": 15 | |
| } | |
| } | |
| } | |
| } | |
| JSON | |
| JSON::Validator.validate!(JSON.parse(json_schema), JSON.parse(json_data.to_json)) | 
      
      
  Author
  
  
        
      
            SpringMT
  
      
      
      commented 
        Jan 23, 2015 
      
    
  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment