How do I convert an XML file to JSON without overflowing the stack?

0

I have a huge XML file almost 500MB size. I want to process it and convert it to JSON format with Rust. I have this code but it says :

thread 'main' has overflowed its stack error: process didn't exit successfully: target\debug\epg_to_json_to_db.exe (exit code: 0xc00000fd, STATUS_STACK_OVERFLOW)

This is my code:

extern crate xmlJSON;
extern crate rustc_serialize;
use crate::rustc_serialize::json::ToJson;

use xmlJSON::XmlDocument;
use rustc_serialize::json;
use std::str::FromStr;
use std::fs::File;
use std::io::prelude::*;

fn main() {
    let filename = "myfile.xml";

    let mut f = File::open(filename).expect("file not found");

    let mut contents = String::new();
    f.read_to_string(&mut contents).expect("something went wrong reading the file");

    let document: XmlDocument = XmlDocument::from_str(&mut contents).unwrap();
    let jsn: json::Json = document.to_json(); 
    println!("{}", jsn);
}

What is a good solution here?

json
xml
rust
asked on Stack Overflow Mar 27, 2020 by Abdol Seed • edited Mar 27, 2020 by Shepmaster

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0