Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephane Crozat
hdoc
Commits
be89a50a
Commit
be89a50a
authored
Dec 06, 2015
by
Jean Vintache
Browse files
JsonToXml
parent
1755172d
Changes
1
Hide whitespace changes
Inline
Side-by-side
etherpad_to_hdoc/antce/lib/jsonToXml/src/jsontoxml/JsonToXml.java
View file @
be89a50a
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
jsontoxml
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
org.json.JSONObject
;
import
org.json.XML
;
import
java.util.Scanner
;
import
java.io.PrintWriter
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
/**
*
* @author JeanV
*/
public
class
JsonToXml
{
/**
* @param args the command line arguments
*/
public
static
void
main
(
String
[]
args
)
{
// TODO code application logic here
// args[0] should hold a JSON file path.
if
(
args
.
length
==
0
)
{
return
;
}
try
{
String
jsonText
=
new
Scanner
(
new
File
(
args
[
0
])).
useDelimiter
(
"\\Z"
).
next
();
JSONObject
json
=
new
JSONObject
(
jsonText
);
String
xml
=
XML
.
toString
(
json
);
PrintWriter
out
=
new
PrintWriter
(
"json_xml_out.xml"
);
out
.
println
(
xml
);
out
.
close
();
}
catch
(
FileNotFoundException
ex
)
{
Logger
.
getLogger
(
JsonToXml
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment