A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on IRC (such as one of these permanent autoconfirmed members).

Difference between revisions of "Validator.nu JSON Output"

From WHATWG Wiki
Jump to: navigation, search
(The <code>"class"</code> ''string'')
(Example: Fixed syntax errors in the example)
Line 53: Line 53:
  
 
<pre><nowiki>{
 
<pre><nowiki>{
"url": "http://example.org/"
+
"url": "http://example.org/",
"messages": [
+
"messages": [{
{
+
"class"  : "info",
"class"  : "info"
 
 
"line"  : 20,
 
"line"  : 20,
 
"column" : 15,
 
"column" : 15,
 
"url"    : "http://example.com/",
 
"url"    : "http://example.com/",
 
"type"  : "warning",
 
"type"  : "warning",
"message": "Trailing slash for void element"
+
"message": "Trailing slash for void element",
"extract": "<br/>"
+
"extract": "<br/>",
 
"offset": 3
 
"offset": 3
 
},
 
},
 
{
 
{
"class"  : "error"
+
"class"  : "error",
 
"line"  : 42,
 
"line"  : 42,
 
"column" : 17,
 
"column" : 17,
 
"url"    : "http://example.com/",
 
"url"    : "http://example.com/",
 
"type"  : "fatal",
 
"type"  : "fatal",
"message": "Missing end tag for the “foo” element"
+
"message": "Missing end tag for the <code>foo</code> element",
}
+
}],
],
 
 
"result": {
 
"result": {
 
"type"  : "failure",
 
"type"  : "failure",
Line 84: Line 82:
 
}
 
}
 
}
 
}
}</nowiki></pre>
+
};</nowiki></pre>
  
 
==Processing Model==
 
==Processing Model==

Revision as of 17:36, 11 September 2007

This is a draft of a Web service response format for Validator.nu for clients that prefer JSON over XML.

Italicized words, such as object, refer to JSON data types.

Root Object

The root object is a JSON object. It has two mandatory keys, "messages" and "result", and three optional keys, "url", "source" and "parse-tree".

The values for these keys are described below.

The "messages" array

The this array is an ordered collection of zero or more message objects.

Message objects

A message object has one mandatory key, "class", and seven optional keys, "type", "message", "extract", "offset", "url", "line" and "column".

The "class" string

The "class" string denotes the general class of the message. The permissible values are "info", "error" and "non-document-error".

"info" means an informational message or warning that does not affect the validity of the document being checked. "error" signifies a problem that causes the validation/checking to fail. "non-document-error" signifies an error that causes the checking to end in an indeterminate state because the document being validated could not be examined to the end. Examples of such errors include broken schemas, bugs in the validator and IO errors. (Note that when a schema has parse errors, they are first reported as errors and then a catch-all non-document-error is also emitted.)

The "type" string
The "message" string
The "extract" string
The "offset" number
The "url" string
The "line" number
The "column" number

The "url" string

The "result" object

The "source" object

The "parse-tree" object

Example

{
	"url": "http://example.org/",
	"messages": [{
			"class"  : "info",
			"line"   : 20,
			"column" : 15,
			"url"    : "http://example.com/",
			"type"   : "warning",
			"message": "Trailing slash for void element",
			"extract": "<br/>",
			"offset": 3
		},
		{
			"class"  : "error",
			"line"   : 42,
			"column" : 17,
			"url"    : "http://example.com/",
			"type"   : "fatal",
			"message": "Missing end tag for the <code>foo</code> element",
		}],
	"result": {
		"type"  : "failure",
		"source": {
			"type"    : "text/html",
			"encoding": "UTF-8"
		},
		"parse-tree": {
			...
		}
	}
};

Processing Model

See also