Solution:
I found the problem, that is stylus parser rewrite the function toJSON, so although the ast print like following, but actually ast object don't have __type property, so it causes the problem.
Question:
I am using stylus ast tree which is like :
{
"__type": "Root",
"nodes": [
{
"__type": "Ident",
"name": "some-mixin",
"val": {
"__type": "Function",
"name": "some-mixin",
"lineno": 1,
"column": 16,
"params": {
"__type": "Params",
"nodes": [
{
"__type": "Ident",
"name": "a",
"val": {
"__type": "Null"
},
"mixin": false,
"lineno": 1,
"column": 12
},
...
it's a tree expressed by json.
and I want to get value of "__type", but using ["__type"] to get the value, undefined is returned.
it seems like "__type" has some special meaning in json, how can I get the value of "__type"?
PS:
I tried object.__type
to get the value, it doesn't work.
In addition, I found some weird thing
typeof ast // returns object
I use JSON.stringify(ast), and __type is in the string But I use console.log(ast), __type is missing, I don't know why..
And also I tried
console.log(ast.hasOwnProperty('__type')) //return false
PPS: I run this code in node v0.12.0
Thanks for your help!