forked from dscape/clarinet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
23 lines (21 loc) · 783 Bytes
/
example.js
File metadata and controls
23 lines (21 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var clarinet = require("clarinet")
var parser = clarinet.parser();
parser.onvalue = function (v) {
console.log("Value: " + v);
};
parser.onkey = function (key) {
console.log("Key: " + key);
};
parser.onopenobject = function () {
console.log("New Object");
}
parser.oncloseobject = function () {
console.log("Close Object");
}
parser.onopenarray = function () {
console.log("New Array");
}
parser.onclosearray = function () {
console.log("Close Array");
}
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();