Feb
21
2012

MooTools String.isJSON

Today I had a need to quickly test if a string was valid JSON and return a simple boolean

Tested with mootools 1.4+

String.implement({
	isJSON: function() {
		return (!this || typeOf(this) != 'string' || !JSON.validate(this)) ? false : true;
	}
});

Leave a comment

Show/Hide Footer Actions

Status: Available for your project.