summary refs log tree commit diff stats
path: root/lib/pure/json.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-06-26 17:21:52 +0200
committerAraq <rumpf_a@web.de>2011-06-26 17:21:52 +0200
commit990dc2d7152f09c413d8fd96d66484d79aec97c7 (patch)
treea267c16996c61292c78019ab56d1116d811fd0dc /lib/pure/json.nim
parentdb0a4a9f86d167faccbd50f3f12f9de470e516b8 (diff)
downloadNim-990dc2d7152f09c413d8fd96d66484d79aec97c7.tar.gz
code gen bugfixes; marshal.nim implemented
Diffstat (limited to 'lib/pure/json.nim')
-rwxr-xr-xlib/pure/json.nim11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 7b2707784..7c4961b61 100755
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -22,7 +22,7 @@ type
     jsonError,           ## an error ocurred during parsing
     jsonEof,             ## end of file reached
     jsonString,          ## a string literal
-    jsonInt,             ## a integer literal
+    jsonInt,             ## an integer literal
     jsonFloat,           ## a float literal
     jsonTrue,            ## the value ``true``
     jsonFalse,           ## the value ``false``
@@ -121,7 +121,7 @@ proc str*(my: TJsonParser): string {.inline.} =
 proc getInt*(my: TJsonParser): biggestInt {.inline.} = 
   ## returns the number for the event: ``jsonInt``
   assert(my.kind == jsonInt)
-  return parseInt(my.a)
+  return parseBiggestInt(my.a)
 
 proc getFloat*(my: TJsonParser): float {.inline.} = 
   ## returns the number for the event: ``jsonFloat``
@@ -512,9 +512,10 @@ type
     of JArray:
       elems*: seq[PJsonNode]
 
-  EJsonParsingError* = object of EInvalidValue
+  EJsonParsingError* = object of EInvalidValue ## is raised for a JSON error
 
-proc raiseParseErr(p: TJsonParser, msg: string) =
+proc raiseParseErr*(p: TJsonParser, msg: string) {.noinline, noreturn.} =
+  ## raises an `EJsonParsingError` exception.
   raise newException(EJsonParsingError, errorMsgExpected(p, msg))
 
 proc newJString*(s: String): PJsonNode =
@@ -607,6 +608,7 @@ proc `[]=`*(obj: PJsonNode, key: String, val: PJsonNode) =
   obj.fields.add((key, val))
 
 proc delete*(obj: PJsonNode, key: string) =
+  ## Deletes ``obj[key]`` preserving the order of the other (key, value)-pairs.
   assert(obj.kind == JObject)
   for i in 0..obj.fields.len-1:
     if obj.fields[i].key == key:
@@ -615,6 +617,7 @@ proc delete*(obj: PJsonNode, key: string) =
   raise newException(EInvalidIndex, "key not in object")
 
 proc copy*(p: PJsonNode): PJsonNode =
+  ## Performs a deep copy of `a`.
   case p.kind
   of JString:
     result = newJString(p.str)