Monday, 24 April 2017

Calling variable from jason

Initially i read data from xml file and stored in varible xml, later i converted into jason format and saved it in variable json. Following is the data saved in variable Jason in json format.

{ 'maven2-moduleset':
       { '$': { plugin: 'maven-plugin@2.15.1' },
         actions: [ '' ],
         description: [ '' ],
         keepDependencies: [ 'false' ],
         properties: [ [Object] ],
         scm: [ [Object] ]}}

when I'm trying too access

console.log(jason.maven2-moduleset.$.scm)

it's throwing following error

events.js:154
      throw er; // Unhandled 'error' event
      ^

ReferenceError: moduleset is not defined
    at /NodeJS/configxml/configxml.js:20:62
    at Parser.<anonymous> (/NodeJS/configxml/node_modules/xml2js/lib/xml2js.js:489:18)
    at emitOne (events.js:90:13)
    at Parser.emit (events.js:182:7)
    at Object.onclosetag (/NodeJS/configxml/node_modules/xml2js/lib/xml2js.js:447:26)
    at emit (/NodeJS/configxml/node_modules/sax/lib/sax.js:640:35)
    at emitNode (/NodeJS/configxml/node_modules/sax/lib/sax.js:645:5)
    at closeTag (/NodeJS/configxml/node_modules/sax/lib/sax.js:905:7)
    at Object.write (/NodeJS/configxml/node_modules/sax/lib/sax.js:1452:13)
    at Parser.exports.Parser.Parser.parseString (/NodeJS/configxml/node_modules/xml2js/lib/xml2js.js:508:31)

I want to get data in 'scm' , Don't know where I'm doing wrong. Could tell me how to display data in scm object.



via Lakshmi

No comments:

Post a Comment