Galera estou usando XStream para gerar meu .json.
Preciso salva-lo em uma pasta, e manipular ele.
Exemplo crio o json, salvo com o nome xpto.json e entao altero, incluo, excluo informações nele. Sempre mantendo-o atualizado.
Tentei algo como:
public class Main {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
CreateJson createJson = new CreateJson();
Veiculo terra = new Veiculo("vectra");
Veiculo uol = new Veiculo("uol");
Formato fullexpand = new Formato().Name("Full Expansivel").Width(468).Height(300).Weight(new Weight(10, 10)).Framerate(18).ServedByTag(true).WeightVideo(24).TypeWeightVideo("mb").TimeAnimation(15).CodeToBeUsed(new CodeToBeUsed("Expandable v2(concencional)", "Expandable v2 Polite(Richmedia)")).PoiStandard("Expandiu", "Retraiu").Observation("script Mouse Over: getURL('javascript:opn(1)');").create();
Formato arroba = new Formato().Name("Arroba Banner").Width(468).Height(300).Weight(new Weight(10, 10)).Framerate(18).ServedByTag(true).WeightVideo(24).TypeWeightVideo("mb").TimeAnimation(15).CodeToBeUsed(new CodeToBeUsed("Expandable v2(concencional)", "Expandable v2 Polite(Richmedia)")).PoiStandard("Expandiu").Observation("script Mouse Over: getURL('javascript:opn(1)');").create();
terra.add(arroba);
uol.add(fullexpand);
createJson.setVeiculo(terra);
createJson.setVeiculo(uol);
File file = new File("./xml/specs.json");
file.createNewFile();
try {
FileOutputStream fos = new FileOutputStream(file);
createJson.getXstream().toXML(createJson.show(), fos);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(createJson.show());
}
}
Mas ele gera um .json estranho:
{“string”: "{“referenceguideadmotion”: {\u000a “veiculo”:…
E nao consegui manipula-lo e “salvar por cima”.
Alguem poderia me ajudar.
Agradeço desde ja.