changeset 165:fe816637fcc4

Add support for parsing true and false to JSON parser
author Mike Pavone <pavone@retrodev.com>
date Sun, 11 Aug 2013 00:58:50 -0700
parents 75be44ed9df5
children e7642715d575
files modules/json.tp
diffstat 1 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/modules/json.tp	Sat Aug 10 22:26:26 2013 -0700
+++ b/modules/json.tp	Sun Aug 11 00:58:50 2013 -0700
@@ -12,6 +12,8 @@
 	comma <- "," byte: 0
 	tab <- "\t" byte: 0
 	colon <- ":" byte: 0
+	t <- "t" byte: 0
+	f <- "f" byte: 0
 
 	parseNumAt <- :str :at :recvResult {
 		num <- 0
@@ -122,10 +124,25 @@
 							value <- val
 						}
 					} else: {
-						#{
-							value <- "foobar"
-							after <- (text length)
+						if: b = t && (text from: cur withLength: 4) = "true" {
+							#{
+								value <- true
+								after <- cur + 4
+							}
+						} else: {
+							if: b = f && (text from: cur withLength: 5) = "false" {
+								#{
+									value <- false
+									after <- cur + 5
+								}
+							} else: {
+								#{
+									value <- "foobar"
+									after <- (text length)
+								}
+							}
 						}
+
 					}
 				}
 			}