Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Off by one character #2

jmakeig opened this Issue Mar 25, 2012 · 3 comments


None yet
2 participants

jmakeig commented Mar 25, 2012

Using, what I hoped was the simplest set-up, it seems to be parsing, but all of my keys and values are off by one character.

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8" />
    <script type="text/javascript">var exports = {};</script>
    <script type="text/javascript" src="../lib/clarinet.js"></script>
    <script type="text/javascript">
    var parser = exports.parser();
    parser.onvalue = function (v) {
      console.log("Value: " + v);
    parser.onkey = function (key) {
      console.log("Key: " + key);
    parser.write('{ "firstName": "John", "lastName" : "Smith", "age" : 25, "address" : { "streetAddress": "21 2nd Street", "city" : "New York", "state" : "NY", "postalCode" : "10021" }, "phoneNumber": [ { "type" : "home", "number": "212 555-1234" }, { "type" : "fax", "number": "646 555-4567" } ] }').close();
  Look at the console.

results in

Value: ohn
Key: astName
Value: mith
Key: ge
Value: 25
Key: ddress
Value: 1 2nd Street
Key: ity
Value: ew York
Key: tate
Value: Y
Key: ostalCode
Value: 0021
Key: honeNumber
Value: ome
Key: umber
Value: 12 555-1234
Value: ax
Key: umber
Value: 46 555-4567

This is happening in Chrome 17.0.963.79. Am I doing something dumb?


dscape commented Mar 26, 2012

I remember a pull request that introduced this problem, but I then fixed it.

Maybe you are using a old version?

I'm going to check the code base now

dscape added a commit that referenced this issue Mar 26, 2012


dscape commented Mar 26, 2012

Hi Justin,

Thanks for the awesome sample, I've added it to the samples directory and took the liberty of adding you to the contributors.


Will be published as clarinet@0.5.8


dscape commented Mar 26, 2012

Justin please try the most recent version of clarinet.


@dscape dscape closed this Mar 26, 2012

dscape pushed a commit that referenced this issue Dec 17, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment