Xmljson a Swift CLI Tool to Convert XML to JSON

栏目: IT技术 · 发布时间: 6年前

内容简介:A Swift command-line tool to easily convert XML format to JSON.First specify where the xml files are located through

XMLJSON

A Swift command-line tool to easily convert XML format to JSON.

Xmljson a Swift CLI Tool to Convert XML to JSON

Requirements

  • Good Mood

Usage

$ xmljson -h
OVERVIEW: Convert XML Format to JSON Format.
USAGE: xmljson --dir <dir> [--files <files> ...] [--output <output>] [--verbose] [--all]

OPTIONS:
  -d, --dir <dir>         Absolute path to a directory containing the xml files.
  -f, --files <files>     XML files to be parsed.
  -o, --output <output>   [Optinal] JSON file(s) output directory.
  -v, --verbose           Show extra logging for debugging purposes.
  -a, --all               Convert all XML files present in the specifed directory.
  -h, --help              Show help information.

First specify where the xml files are located through --dir argument (Manadatory) Then you can specify the files to be converted in through --files argument you can pass as much as you want

$ xmljson -d ~/xml/files/dir - file1.xml filen.xml --verbose

If you want to convert all the XML files present in the directory, pass the --dir argument and --all flag only.

$ xmljson -d ~/xml/files/dir  --all

if you would like to change the output directory pass it to --output .

$ xmljson -d ~/xml/files/dir  -o ~/path/to/output/dir --all

Sample

XML Input

?xml version="1.0" encoding="UTF-8"?>
<bookstore>
  <book category="cooking">
    <title lang="en">Everyday 1</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
  </book>
  <book category="web">
    <title lang="en">Learning XML</title>
    <author>Erik T. Ray</author>
    <year>2003</year>
    <price>39.95</price>
  </book>
</bookstore>

JSON Output

[
  {
    "author" : "Giada De Laurentiis",
    "title" : {
      "lang" : "en",
      "text" : "Everyday 1"
    },
    "year" : "2005",
    "category" : "cooking",
    "price" : "30.00"
  },
  {
    "author" : "Erik T. Ray",
    "title" : {
      "lang" : "en",
      "text" : "Learning XML"
    },
    "year" : "2003",
    "category" : "web",
    "price" : "39.95"
  }
]

Installation using HomeBrew

You can install xmljson using homebrew as follows:

$ brew tap engali94/formulae
$ brew install xmljson

Installation using Make

You can install xmljson using make as follows:

$ git clone https://github.com/engali94/XMLJson.git
$ cd XMLJson
$ make install

Development

  • cd into the repository

  • run swift package generate-xcodeproj

  • Run the following command to try it out:

    swift run XMLJson --help

License

XMLJson is released under the MIT license. See LICENSE for more information.


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。

模式识别

模式识别

(希)Sergios Theodoridis、(希)Konstantinos Koutroumbas / 电子工业出版社 / 2010-2 / 75.00元

本书全面阐述了模式识别的基础理论、最新方法以及各种应用。模式识别是信息科学和人工智能的重要组成部分,主要应用领域有图像分析、光学字符识别、信道均衡、语言识别和音频分类等。本书在完美地结合当前的理论与实践的基础上,讨论了贝叶斯分类、贝叶斯网络、线性和非线性分类器设计、上下文相关分类、特征生成、特征选取技术、学习理论的基本概念以及聚类概念与算法。与前一版相比,增加了大数据集和高维数据相关的最新算法,这......一起来看看 《模式识别》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

MD5 加密
MD5 加密

MD5 加密工具

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具