Skip to content

Latest commit

 

History

History
28 lines (21 loc) · 1.32 KB

README.md

File metadata and controls

28 lines (21 loc) · 1.32 KB

jsmn.nim

Jsmn - a world fastest JSON parser - in pure Nim

According to this benchmark script with about 3MB JSON of World Bank dataset, JSMN is 2-2.5 times faster than marshal Benchmark result

Benchmark result

Usage

import jsmn
const
  json = """{
    "user": "johndoe",
    "admin": false,
    "uid": 1000,
    "groups": ["users", "wheel", "audio", "video"]}"""

var tokens = newSeq[JsmnToken](32) # expect not more than 32 tokens
let r = parseJson(json, tokens)

for i in 1..r:
  var token = addr tokens[i]
  echo "Kind: ", token.kind
  echo "Value: ", json[token.start..<token.stop]