happiness1210
65
2018-07-12 05:46:56 작성 2018-07-12 06:09:45 수정됨
2
73

nodejs 에서 파일 입출력 관련입니다.


안녕하세요!

아래와 같은 결과값이 있는데 이게 정확히 JSON 형식은 아닌거 같은데, 여기에서 결과값을 빼내올라면 어떻게 해야할까요?

우선 fs 모듈로 파일을 저장한다음, 원하는 결과값을 얻으려면 어떻게 해야하는지 궁금합니다. 


해결책 알려주시는분께 무더운 여름 베스킨 라빈스 기프트콘 한개 보내드리겠습니다^^ 


{  info: { status:   "0000",
             data: {        total_krw:  0,
                           in_use_krw:  0,
                        available_krw:  0,
                             misu_krw:  0,
                            total_btc: "0.00002614",
                           in_use_btc: "0.00000000",
                        available_btc: "0.00002614",
                             misu_btc: "0.00000000",
                       xcoin_last_btc: "7231000",
                            total_eth: "0.000000000000000000",
                           in_use_eth: "0.00000000",
                        available_eth: "0.00000000",
                             misu_eth:  0,
                       xcoin_last_eth: "498000",
                           total_dash: "0.00000000",
                          in_use_dash: "0.00000000",
                       available_dash: "0.00000000",
                            misu_dash:  0,
                      xcoin_last_dash: "246000",
                            total_ltc: "0.00009065",
                           in_use_ltc: "0.00000000",
                        available_ltc: "0.00009065",
                             misu_ltc:  0,
                       xcoin_last_ltc: "87600",
                            total_etc: "0.000048700344800000",
                           in_use_etc: "0.00000000",
                        available_etc: "0.00004870",
                             misu_etc:  0,
                       xcoin_last_etc: "18530",
                            total_xrp: "0.000091",
                           in_use_xrp: "0.00000000",
                        available_xrp: "0.00009100",
                             misu_xrp:  0,
                       xcoin_last_xrp: "508",
                            total_bch: "0.00001957",
                           in_use_bch: "0.00000000",
                        available_bch: "0.00001957",
                             misu_bch:  0,
                       xcoin_last_bch: "795000",
                            total_xmr: "0.000000000000",
                           in_use_xmr: "0.00000000",
                        available_xmr: "0.00000000",
                             misu_xmr:  0,
                       xcoin_last_xmr: "138700",
                            total_zec: "0.00006407",
                           in_use_zec: "0.00000000",
                        available_zec: "0.00006407",
                             misu_zec:  0,
                       xcoin_last_zec: "176900",
                           total_qtum: "0.00000000",
                          in_use_qtum: "0.00000000",
                       available_qtum: "0.00000000",
                            misu_qtum:  0,
                      xcoin_last_qtum: "9280",
                            total_btg: "0.00000000",
                           in_use_btg: "0.00000000",
                        available_btg: "0.00000000",
                             misu_btg:  0,
                       xcoin_last_btg: "32900",
                            total_eos: "1458.216147200000000000",
                           in_use_eos: "1458.21610000",
                        available_eos: "0.00004720",
                             misu_eos:  0,
                       xcoin_last_eos: "8270",
                            total_icx: "0.000000000000000000",
                           in_use_icx: "0.00000000",
                        available_icx: "0.00000000",
                             misu_icx:  0,
                       xcoin_last_icx: "1855",
                            total_ven: "0.000000000000000000",
                           in_use_ven: "0.00000000",
                        available_ven: "0.00000000",
                             misu_ven:  0,
                       xcoin_last_ven: "2842",
                            total_trx: "0.000030",
                           in_use_trx: "0.00000000",
                        available_trx: "0.00003000",
                             misu_trx:  0,
                       xcoin_last_trx: "40",
                            total_elf: "0.000003500000000000",
                           in_use_elf: "0.00000000",
                        available_elf: "0.00000350",
                             misu_elf:  0,
                       xcoin_last_elf: "917",
                           total_mith: "0.000057885728550000",
                          in_use_mith: "0.00000000",
                       available_mith: "0.00005788",
                            misu_mith:  0,
                      xcoin_last_mith: "550",
                            total_mco: "0.00000000",
                           in_use_mco: "0.00000000",
                        available_mco: "0.00000000",
                             misu_mco:  0,
                       xcoin_last_mco: "8790",
                            total_omg: "0.000000000000000000",
                           in_use_omg: "0.00000000",
                        available_omg: "0.00000000",
                             misu_omg:  0,
                       xcoin_last_omg: "9170",
                            total_knc: "0.000000000000000000",
                           in_use_knc: "0.00000000",
                        available_knc: "0.00000000",
                             misu_knc:  0,
                       xcoin_last_knc: "1272",
                            total_gnt: "0.000074150000000000",
                           in_use_gnt: "0.00000000",
                        available_gnt: "0.00007415",
                             misu_gnt:  0,
                       xcoin_last_gnt: "469",
                            total_hsr: "0.00000000",
                           in_use_hsr: "0.00000000",
                        available_hsr: "0.00000000",
                             misu_hsr:  0,
                       xcoin_last_hsr: "6830",
                            total_zil: "0.000073150000",
                           in_use_zil: "0.00000000",
                        available_zil: "0.00007315",
                             misu_zil:  0,
                       xcoin_last_zil: "97",
                          total_ethos: "0.00000000",
                         in_use_ethos: "0.00000000",
                      available_ethos: "0.00000000",
                           misu_ethos:  0,
                     xcoin_last_ethos: "2819",
                            total_pay: "0.000000000000000000",
                           in_use_pay: "0.00000000",
                        available_pay: "0.00000000",
                             misu_pay:  0,
                       xcoin_last_pay: "2998",
                            total_wax: "0.00009890",
                           in_use_wax: "0.00000000",
                        available_wax: "0.00009890",
                             misu_wax:  0,
                       xcoin_last_wax: "613",
                           total_powr: "0.000000",
                          in_use_powr: "0.00000000",
                       available_powr: "0.00000000",
                            misu_powr:  0,
                      xcoin_last_powr: "987",
                            total_lrc: "0.000000000000000000",
                           in_use_lrc: "0.00000000",
                        available_lrc: "0.00000000",
                             misu_lrc:  0,
                       xcoin_last_lrc: "1011",
                            total_gto: "0.00006",
                           in_use_gto: "0.00000000",
                        available_gto: "0.00006000",
                             misu_gto:  0,
                       xcoin_last_gto: "517",
                          total_steem: "0.000",
                         in_use_steem: "0.00000000",
                      available_steem: "0.00000000",
                           misu_steem:  0,
                     xcoin_last_steem: "2649",
                          total_strat: "0.00000000",
                         in_use_strat: "0.00000000",
                      available_strat: "0.00000000",
                           misu_strat:  0,
                     xcoin_last_strat: "4695",
                            total_zrx: "0.000000000000000000",
                           in_use_zrx: "0.00000000",
                        available_zrx: "0.00000000",
                             misu_zrx:  0,
                       xcoin_last_zrx: "1600",
                            total_rep: "0.000000000000000000",
                           in_use_rep: "0.00000000",
                        available_rep: "0.00000000",
                             misu_rep:  0,
                       xcoin_last_rep: "47820",
                             total_ae: "0.000000000000000000",
                            in_use_ae: "0.00000000",
                         available_ae: "0.00000000",
                              misu_ae:  0,
                        xcoin_last_ae: "3053",
                            total_xem: "0.000000",
                           in_use_xem: "0.00000000",
                        available_xem: "0.00000000",
                             misu_xem:  0,
                       xcoin_last_xem: "337",
                            total_snt: "0.000007950000000000",
                           in_use_snt: "0.00000000",
                        available_snt: "0.00000795",
                             misu_snt:  0,
                       xcoin_last_snt: "287",
                            total_ada: "0.000063",
                           in_use_ada: "0.00000000",
                        available_ada: "0.00006300",
                             misu_ada:  0,
                       xcoin_last_ada: "179"                      } },
    ADA: { free: 0.000063, used: 0, total: 0.000063 },
     AE: { free: 0, used: 0, total: 0 },
    BCH: { free: 0.00001957, used: 0, total: 0.00001957 },
    BTC: { free: 0.00002614, used: 0, total: 0.00002614 },
    BTG: { free: 0, used: 0, total: 0 },
   DASH: { free: 0, used: 0, total: 0 },
    ELF: { free: 0.0000035, used: 0, total: 0.0000035 },
    EOS: {  free: 0.0000472,
            used: 1458.2161,
           total: 1458.2161472 },
    ETC: {  free: 0.0000487,
            used: 0,
           total: 0.0000487003448 },
    ETH: { free: 0, used: 0, total: 0 },
  ETHOS: { free: 0, used: 0, total: 0 },
    GNT: { free: 0.00007415, used: 0, total: 0.00007415 },
    GTO: { free: 0.00006, used: 0, total: 0.00006 },
    HSR: { free: 0, used: 0, total: 0 },
    ICX: { free: 0, used: 0, total: 0 },
    KNC: { free: 0, used: 0, total: 0 },
    KRW: { free: 0, used: 0, total: 0 },
    LRC: { free: 0, used: 0, total: 0 },
    LTC: { free: 0.00009065, used: 0, total: 0.00009065 },
    MCO: { free: 0, used: 0, total: 0 },
   MITH: {  free: 0.00005788,
            used: 0,
           total: 0.00005788572855 },
    OMG: { free: 0, used: 0, total: 0 },
    PAY: { free: 0, used: 0, total: 0 },
   POWR: { free: 0, used: 0, total: 0 },
   QTUM: { free: 0, used: 0, total: 0 },
    REP: { free: 0, used: 0, total: 0 },
    SNT: { free: 0.00000795, used: 0, total: 0.00000795 },
  STEEM: { free: 0, used: 0, total: 0 },
  STRAT: { free: 0, used: 0, total: 0 },
    TRX: { free: 0.00003, used: 0, total: 0.00003 },
    VEN: { free: 0, used: 0, total: 0 },
    WAX: { free: 0.0000989, used: 0, total: 0.0000989 },
    XEM: { free: 0, used: 0, total: 0 },
    XMR: { free: 0, used: 0, total: 0 },
    XRP: { free: 0.000091, used: 0, total: 0.000091 },
    ZEC: { free: 0.00006407, used: 0, total: 0.00006407 },
    ZIL: { free: 0.00007315, used: 0, total: 0.00007315 },
    ZRX: { free: 0, used: 0, total: 0 },
   free: {   ADA: 0.000063,
              AE: 0,
             BCH: 0.00001957,
             BTC: 0.00002614,
             BTG: 0,
            DASH: 0,
             ELF: 0.0000035,
             EOS: 0.0000472,
             ETC: 0.0000487,
             ETH: 0,
           ETHOS: 0,
             GNT: 0.00007415,
             GTO: 0.00006,
             HSR: 0,
             ICX: 0,
             KNC: 0,
             KRW: 0,
             LRC: 0,
             LTC: 0.00009065,
             MCO: 0,
            MITH: 0.00005788,
             OMG: 0,
             PAY: 0,
            POWR: 0,
            QTUM: 0,
             REP: 0,
             SNT: 0.00000795,
           STEEM: 0,
           STRAT: 0,
             TRX: 0.00003,
             VEN: 0,
             WAX: 0.0000989,
             XEM: 0,
             XMR: 0,
             XRP: 0.000091,
             ZEC: 0.00006407,
             ZIL: 0.00007315,
             ZRX: 0           },
   used: {   ADA: 0,
              AE: 0,
             BCH: 0,
             BTC: 0,
             BTG: 0,
            DASH: 0,
             ELF: 0,
             EOS: 1458.2161,
             ETC: 0,
             ETH: 0,
           ETHOS: 0,
             GNT: 0,
             GTO: 0,
             HSR: 0,
             ICX: 0,
             KNC: 0,
             KRW: 0,
             LRC: 0,
             LTC: 0,
             MCO: 0,
            MITH: 0,
             OMG: 0,
             PAY: 0,
            POWR: 0,
            QTUM: 0,
             REP: 0,
             SNT: 0,
           STEEM: 0,
           STRAT: 0,
             TRX: 0,
             VEN: 0,
             WAX: 0,
             XEM: 0,
             XMR: 0,
             XRP: 0,
             ZEC: 0,
             ZIL: 0,
             ZRX: 0          },
  total: {   ADA: 0.000063,
              AE: 0,
             BCH: 0.00001957,
             BTC: 0.00002614,
             BTG: 0,
            DASH: 0,
             ELF: 0.0000035,
             EOS: 1458.2161472,
             ETC: 0.0000487003448,
             ETH: 0,
           ETHOS: 0,
             GNT: 0.00007415,
             GTO: 0.00006,
             HSR: 0,
             ICX: 0,
             KNC: 0,
             KRW: 0,
             LRC: 0,
             LTC: 0.00009065,
             MCO: 0,
            MITH: 0.00005788572855,
             OMG: 0,
             PAY: 0,
            POWR: 0,
            QTUM: 0,
             REP: 0,
             SNT: 0.00000795,
           STEEM: 0,
           STRAT: 0,
             TRX: 0.00003,
             VEN: 0,
             WAX: 0.0000989,
             XEM: 0,
             XMR: 0,
             XRP: 0.000091,
             ZEC: 0.00006407,
             ZIL: 0.00007315,
             ZRX: 0                 }                                  }
0
0
  • 답변 2

  • 세브라이드
    849
    2018-07-12 07:17:11 작성 2018-07-12 07:17:35 수정됨

    오브젝트일 경우

    fs.writeSync(JSON.stringify(object))

    fs.readSync(JSON.parse(object))

    스트링일 경우

    > npm i -s JSON5

    const JSON5 = require('JSON5')

    fs.writeSync(string)

    fs.readSync(JSON5.parse(string))


    기억으로 적은거라 문법이 다소 틀릴 수 있습니다

    0
  • happiness1210
    65
    2018-07-17 18:48:21

    다른 방법으로 해결이 가능하여 해결했습니다^^ 감사합니다!

    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.