什么是Node JS的XML转换器模块的最佳JSON或JS对象

 等艺来绵阳 发布于 2023-01-08 14:53

我需要构建一个相对简单的XML文档,其中包含一些层次结构和JS对象的一些属性.在选择其中一个模块之前,我现在站了起来:

https://github.com/davidcalhoun/jstoxml

https://github.com/soldair/node-jsontoxml

https://github.com/QuickenLoans/node-easyxml

https://github.com/michaelkourlas/node-js2xmlparser

我应该选择哪个模块?

这个问题可能会被认为不是一个好问题,但我不知道如何以不同的方式提出这个问题.

免责声明:我在每个存储库上发布了相同的问题作为问题

这是我想要构建的XML:



    
        123123
        345345
        7604
        qwert
        0
        GB
        
        
        
        02
        
        
        
        
        
        
            
            0
            qwerty
            Q.W.E
            
            Qwerty
            Some company
            Postbus
            13
            
            1234 AB
            THERE
            NL
            a@b.nl
            0168-123456
            06-12345678
        
        
            
                1234
                8765432
                164-05-366
                2
                Some gift voucher
                1233
            
            
                5678
                8765432
                164-05-367
                3
                Some other gift voucher
                1244
            
        
    

Christiaan W.. 37

我调查了自己

| author        | davidcalhoun | soldair   | QuickenLoans | michaelkourlas |
|---------------|--------------|-----------|--------------|----------------|
| module        | jstoxml      | node-     | node-        | node-          |
|               |              | jsontoxml | easyxml      | js2xmlparser   |
| Commits       | 31           | 64        | 39           | 61             |
| Recent commit | a year ago   | 2 years ag| 6 months ago | 16 days ago    |
| Contributors  | 2            | 7         | 7            | 6              |
| Issues        | 16           | 19        | 17           | 15             |
| Open Issues   | 7            | 1         | 6            | 1              |
| npm install   |  jstoxml     | not found | easyxml      | js2xmlparser   |
| Dependencies  | None         | None      | elementtree, | None           |
|               |              |           | inflect      |                |
| Throws errors | None         | None      | 3            | 12             |

然后是比较所需的对象类型

davidcalhoun/jstoxml:

{
  "_name": 'foo',
  "_content": 'bar',
  "_attrs": {
    "a": 'b',
    "c": 'd'
  }
}

soldair/node-jsontoxml:看起来很复杂

QuickenLoans/easyxml:

items: [{
    "name": 'one',
    "_id": 1
  }, {
    "name": 'two',
    "_id": 2
  }
]

michaelkourlas /节点js2xmlparser

foo: {
  "#": 'bar',
  "@": {
    a: 'b',
    c: 'd'
  }
}

我想我会给michaelkourlas的node-js2xmlparser一个镜头.

更新:现在看来还有2个值得一提:

chilts/data2xml

oozcitak/xmlbuilder-JS

后者是迄今为止最成熟的并且在npm下载.它允许您一次性或迭代地构建XML.

1 个回答
  • 我调查了自己

    | author        | davidcalhoun | soldair   | QuickenLoans | michaelkourlas |
    |---------------|--------------|-----------|--------------|----------------|
    | module        | jstoxml      | node-     | node-        | node-          |
    |               |              | jsontoxml | easyxml      | js2xmlparser   |
    | Commits       | 31           | 64        | 39           | 61             |
    | Recent commit | a year ago   | 2 years ag| 6 months ago | 16 days ago    |
    | Contributors  | 2            | 7         | 7            | 6              |
    | Issues        | 16           | 19        | 17           | 15             |
    | Open Issues   | 7            | 1         | 6            | 1              |
    | npm install   |  jstoxml     | not found | easyxml      | js2xmlparser   |
    | Dependencies  | None         | None      | elementtree, | None           |
    |               |              |           | inflect      |                |
    | Throws errors | None         | None      | 3            | 12             |
    

    然后是比较所需的对象类型

    davidcalhoun/jstoxml:

    {
      "_name": 'foo',
      "_content": 'bar',
      "_attrs": {
        "a": 'b',
        "c": 'd'
      }
    }
    

    soldair/node-jsontoxml:看起来很复杂

    QuickenLoans/easyxml:

    items: [{
        "name": 'one',
        "_id": 1
      }, {
        "name": 'two',
        "_id": 2
      }
    ]
    

    michaelkourlas /节点js2xmlparser

    foo: {
      "#": 'bar',
      "@": {
        a: 'b',
        c: 'd'
      }
    }
    

    我想我会给michaelkourlas的node-js2xmlparser一个镜头.

    更新:现在看来还有2个值得一提:

    chilts/data2xml

    oozcitak/xmlbuilder-JS

    后者是迄今为止最成熟的并且在npm下载.它允许您一次性或迭代地构建XML.

    2023-01-08 14:55 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有