proger89 / convert-types
dev-main
2023-01-12 11:24 UTC
Requires
- colinodell/json5: ^2.3
- jtrumbull/xml-parser: ^1.0
- shtrihstr/html-serializer: dev-master
This package is auto-updated.
Last update: 2025-03-12 16:18:30 UTC
README
Convert to different formats.
For instance:
- XML -> JSON
- JSON -> XML
- HTML -> JSON
- HTML -> XML
etc.
HTML to JSON
$html = "<html><body>Hello <i>This is my car</i></body></html>" $convert = new Convert(); print $convert->to($html,'json')
or use to constant
$convert = new Convert(); print $convert->to($html,Convert::TYPE_JSON)
JSON to XML
$json = "[ { color: "red", value: "#f00" }, { color: "green", value: "#0f0" }, { color: "blue", value: "#00f" }, { color: "cyan", value: "#0ff" }, { color: "magenta", value: "#f0f" }, { color: "yellow", value: "#ff0" }, { color: "black", value: "#000" } ]" $convert = new Convert(); print $convert->to($html,'xml')
or use to constant
$convert = new Convert(); print $convert->to($html,Convert::TYPE_XML)