Last active
March 18, 2022 12:53
-
-
Save TheMartinfer22/88669fc4b1d8822308e806b55d83afaf to your computer and use it in GitHub Desktop.
Para utilizar esse código deve conter o arquivo que irá realizar a verificação, isso é útil para verificar e alterar os campos se caso estiverem em seu formato incorreto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.nio.charset.StandardCharsets; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
public class CSUParseAttributes { | |
public static void main(String[] args) throws IOException { | |
BufferedReader bf = new BufferedReader(new FileReader("PortalAPI.json")); | |
boolean blnExample = false; | |
List<String> stringList = new ArrayList<>(); | |
String valorAnterior = null; | |
List<String> listBF = bf.lines().collect(Collectors.toList()); | |
for (String line : listBF) { | |
if (blnExample){ | |
if (line.contains("integer") | line.contains("number")){ | |
String[] split = valorAnterior.split(":"); | |
String replace = split[1].replace("\"", ""); | |
valorAnterior = split[0] + ": " + replace; | |
stringList.add(valorAnterior); | |
blnExample = false; | |
} | |
if (line.contains("string")){ | |
stringList.add(valorAnterior); | |
} | |
if (line.contains("boolean")){ | |
stringList.add(valorAnterior); | |
} | |
} | |
if (line.contains("example")){ | |
blnExample = true; | |
valorAnterior = line; | |
} else { | |
stringList.add(line); | |
} | |
} | |
BufferedWriter fw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("output.json"), StandardCharsets.UTF_8)); | |
for (String s : stringList) { | |
fw.append(s); | |
} | |
fw.flush(); | |
fw.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment