-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to generate multiple xml files out of json's. #2
Comments
If I understand right, I think it would be easier to use shell utilities to read the text file line by line and feed each line into JSON2XML, like this: #!/bin/bash
count=1
while IFS= read -r line; do
echo "$line" | docker run -i -a stdin -a stdout -a stderr atomgraph/json2xml > "${count}.xml"
count=$((count + 1))
done < "input.txt" The script will produce XML files Note that this requires a newline at the end of |
Yeah, shell script would do the trick.
But I was actually looking for a option to do it in java as my entire
requirement is in java.
Also, let me test once by inserting “\n” manually at the end of line.
Do you have any constructor which takes input as string and not InputStream
or Reader?
Actually I have implemented a Spliterator which is taking care of Stream
and batch of streams and then feeding me a line from my text file.
…On Sat, 7 Dec 2019 at 21:44, Martynas Jusevičius ***@***.***> wrote:
If I understand right, I think it would be easier to use shell utilities
to read the text file line by line and feed each line into JSON2XML, like
this:
#!/bin/bash
count=1while IFS= read -r line; do
echo "$line" | docker run -i -a stdin -a stdout -a stderr atomgraph/json2xml > "${count}.xml"
count=$((count + 1))done < "input.txt"
It will produce XML files 1.xml, 2.xml etc, for each line of JSON.
Note that this requires a newline at the end of input.txt, otherwise the
last line will not be read.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2?email_source=notifications&email_token=ADASESAAVLJRFZG3STBQHPLQXPDW7A5CNFSM4JXL66XKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGGKCMY#issuecomment-562864435>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADASESCEAPP5RXQVVKVTR6TQXPDW7ANCNFSM4JXL66XA>
.
|
What is the problem using your Alternatively, can you read each line into a byte array |
I did some design changes and now getting single json in a single file. This way I would avoid EOF issue and also filename issue. Do you have any idea why it might be throwing that? |
This utility is great for converting a single json but I am facing issue while trying to convert multiple json's.
I have a file which contains multiple json's. Every line is a json and I need to generate that many xml files.
Can you tell me what change would be required so that it reads a line converts that to a new XML file?
I have tried:-
OutputStream outputStream = new FileOutputStream("Path");
then use - new JsonStreamXMLWriter(reader, new BufferedWriter(new OutputStreamWriter(outputStream))).convert();
But it throws below error:-
Exception in thread "main" javax.json.stream.JsonParsingException: Expected EOF token, but got CURLYOPEN
at org.glassfish.json.JsonParserImpl.hasNext(JsonParserImpl.java:361)
Attached in the input json file.
input.txt
?
The text was updated successfully, but these errors were encountered: