This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Talk: simpler JSON validation

  • Loading branch information...
1 parent bd4163c commit 885ccdd1b21addf9b6ab9866645e358d4a12a45e @fvdm committed Sep 14, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 climatecounts.js
View
@@ -115,8 +115,8 @@ var app = {
var data = ''
response.on( 'data', function( part ) { data += part })
response.on( 'end', function() {
- data = data.toString().trim()
- if( data.length >= 2 && data.substr(0,1) == '{' && data.substr( data.length -1, 1 ) == '}' ) {
+ data = data.toString('utf8').trim()
+ if( data.match(/^(\{.*\}|\[.*\])$/) ) {
data = JSON.parse( data )
cb( data[ path ] )
} else {

0 comments on commit 885ccdd

Please sign in to comment.