Skip to content

A header-only C++ library converts XML to JSON

License

Notifications You must be signed in to change notification settings

rocky01/xml2json

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xml2json

A header-only C++ library converts XML to JSON

Usage

xml2json is a header-only C++ library. Just copy the ./include folder to system or project's include path. Two examples are shown in xml2json.cpp and ./test/test.cpp

Build and Run a Command Line Tool

make
./xml2json input.xml

C++ API

std::string xml2json(const char *xml_str)

Description

xml2json is the first carefully written C++ library that converts XML document to JSON format. It's already been used in the soft subtitle cross-domain solution at the server-end of Tencent Video (http://v.qq.com) and its CDNs.

It's simple and fast, and with almost full support for the XML standards.

It follows these simple but carefully considered rules below:

Pattern XML JSON Access
1 <e/> "e": [""] o.e
2 <e>text</e> "e": ["text"] o.e
3 <e name="value" /> "e":[{"$":{"name": "value"}}] o.e.$["name"]
4 <e name="value">text</e> "e": [{ "$":{"name": "value"}, "_": "text" }] o.e["name"] o.e["_"]
5 <e> <a>text</a> <b>text</b> </e> "e": [{ "a": ["text"], "b": ["text"] }] o.e.a o.e.b
6 <e> <a>text</a> <a>text</a> </e> "e": [{ "a": ["text", "text"] }] o.e.a[0] o.e.a[1]
7 <e> text <a>text</a> </e> "e": [{ "_": ["text"], "a": ["text"] }] o.e["_"] o.e.a

Tested Under

  • Linux
  • Mac OS X
  • Windows
  • OpenWRT

Donate

WeChat Pay
AliPay

About

A header-only C++ library converts XML to JSON

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 83.9%
  • HTML 13.1%
  • C 2.8%
  • Makefile 0.2%