mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
@@ -908,14 +908,13 @@ proc parseJson*(s: Stream, filename: string = ""; rawIntegers = false, rawFloats
|
||||
|
||||
when defined(js):
|
||||
from std/math import `mod`
|
||||
import std/jsffi
|
||||
from std/jsffi import JSObject, `[]`, to
|
||||
from std/private/jsutils import getProtoName
|
||||
|
||||
proc parseNativeJson(x: cstring): JSObject {.importjs: "JSON.parse(#)".}
|
||||
|
||||
proc getVarType(x: JSObject): JsonNodeKind =
|
||||
result = JNull
|
||||
proc getProtoName(y: JSObject): cstring
|
||||
{.importjs: "Object.prototype.toString.call(#)".}
|
||||
case $getProtoName(x) # TODO: Implicit returns fail here.
|
||||
of "[object Array]": return JArray
|
||||
of "[object Object]": return JObject
|
||||
|
||||
@@ -36,3 +36,4 @@ when defined(js):
|
||||
proc hasBigUint64Array*(): bool =
|
||||
asm """`result` = typeof BigUint64Array != 'undefined'"""
|
||||
|
||||
proc getProtoName*[T](a: T): cstring {.importjs: "Object.prototype.toString.call(#)".}
|
||||
|
||||
Reference in New Issue
Block a user