title: Parse Javascript To JSON Using Python 3
body: <p>this is a very specific request, and for that i apologise, but i am at a loss for what to do..</p>
  
  <p>for a javascript project i am working on i want to be able to parse javascript with python and i found this implementation`port of the original narcissus called pynarcissus:</p>
  
  <p><a href="https://github.com/jtolds/pynarcissus" rel="nofollow">https://github.com/jtolds/pynarcissus</a></p>
  
  <p>the problem for me is the information is buried in the python class structure.. something with which i am only vaguely competent.. and i want the output to be in JSON</p>
  
  <p>i have tried to mine the data out but each time the JSON is invalid</p>
  
  <p>my question is how would you go about doing something like this? i'd appreciate any specifics because the project contains nested classes of disparate types creating what seems to be a wholly unique problem</p>
  
  <p>here are my attempts:</p>
  
  <ul>
  <li><p>i took the return value for parse() and created a function that descends through the class structure returning values based on their type: 'str', 'int', 'bool', 'NoneType', 'list', 'dict', 'main.Node', 'main.Tokenizer', 'main.Object'; but the returned object is missing some properties in the classes, ie 'type', while retaining others like 'type_', also tokenizer always contains the same values</p></li>
  <li><p>i took the output of the str function that the program prints to stdout, removed the clear and copy functions and the tokenizer: [object Object], then tried to manually add in double quotes where necessary to make the output a valid JSON object.. a few problems here, first off ignoring the tokenizer object seems like i am missing out on vital information, and the other problem was that sometimes there is "value" : "{" and sometimes there is "value" : { .. }, after completing the work the JSON was invalid</p></li>
  <li><p>assuming the issue lied in the "value" : { .. } issue i resolved to add a new function identical the the str function but instead of printing just %s values, it would print \"%s\" where necessary.. now, i could differentiate between "value": "{" and "value" : "{ .. }" but i would have to go through and manually remove the quotes around objects.. after doing so the JSON was invalid</p></li>
  <li><p>i've tried every copy'pasta solution for python class to json from the stacks but the nested aspect of the classes along with the changing types add complexity.. some properties lack a .<strong>dict</strong> even when the type is "class 'dict'" so the one'method'fits'all lambda solutions fail</p></li>
  </ul>