#283 ✓duplicate
David W. Allen

isJSON unreliable for some strings

Reported by David W. Allen | August 16th, 2008 @ 12:09 AM | in 1.7

Some plain strings evaluate as true because of the regex on line 461.

For instance

var testAllen = "allen".isJSON()
var testFlare = "flare".isJSON()
console.assert(testAllen == false)
console.assert(testFlare == false)

Both these assertions will fail (using firebug). However, the following will all pass

var testAllen = "Allen".isJSON()
var testFlare = "Flare".isJSON()
var testRobot = "robot".isJSON()
console.assert(testAllen == false)
console.assert(testFlare == false)
console.assert(testRobot == false)

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins