I have a JSON file which contains key-value information. This information consists of characters that are stored in 8x8 matrices. At the time of reading it, it returns all the contents of the file and what I want to do is to get the value of each line from the matrix.
{"1":"1 1 1 1 1 1 1 1","2":"1 1 O O O O 1 1","3":"1 1 O O O O 1 1","4":"O 1 1 O O 1 1 O","5":"O 1 1 1 1 1 1 O","6":"O O 1 1 1 1 O O","7":"O O O O O O O O","8":"O O O O O O O O","time":"0.2"}
{"1":"1 1 1 1 1 1 1 1","2":"1 1 O O O O 1 1","3":"O 1 1 O O 1 1 O","4":"O 1 1 1 1 1 1 O","5":"O O 1 1 1 1 O O","6":"O O O O O O O O","7":"O O O O O O O O","8":"O O O O O O O O","time":"0.2"}
{"1":"1 1 1 1 1 1 1 1","2":"1 1 O O O O 1 1","3":"1 1 O O O O 1 1","4":"1 1 O O O O 1 1","5":"1 1 O O O O 1 1","6":"1 1 O O O O 1 1","7":"O 1 1 1 1 1 1 O","8":"O O 1 1 1 1 O O","time":"0.2"}
{"1":"1 1 1 1 1 1 1 1","2":"1 1 O O O O 1 1","3":"1 1 O O O O 1 1","4":"O 1 1 O O 1 1 O","5":"O 1 1 1 1 1 1 O","6":"O O 1 1 1 1 O O","7":"O O O O O O O O","8":"O O O O O O O O","time":"0.2"}
{"1":"1 1 1 1 1 1 1 1","2":"1 1 1 O O 1 1 1","3":"O 1 1 1 1 1 1 O","4":"O O 1 1 1 1 O O","5":"O O O O O O O O","6":"O O O O O O O O","7":"O O O O O O O O","8":"O O O O O O O O","time":"0.2"}
{"1":"1 1 1 1 1 1 1 1","2":"1 1 O O O O 1 1","3":"O 1 1 O O 1 1 O","4":"O 1 1 1 1 1 1 O","5":"O O 1 1 1 1 O O","6":"O O O O O O O O","7":"O O O O O O O O","8":"O O O O O O O O","time":"0.2"}
{"1":"1 1 1 1 1 1 1 1","2":"1 1 O O O O 1 1","3":"1 1 O O O O 1 1","4":"1 1 O O O O 1 1","5":"1 1 O O O O 1 1","6":"1 1 O O O O 1 1","7":"O 1 1 1 1 1 1 O","8":"O O 1 1 1 1 O O","time":"0.2"}
That's the content of the file and what it shows me by console and what I want it to show me is only 1 and O.
public static void main(String[] args) throws InterruptedException {
JSONParser parser = new JSONParser();
try {
Object obj = parser.parse(new FileReader("pruebame.json"));
JSONObject jsonObject = (JSONObject) obj;
// loop array
JSONArray tag = (JSONArray) jsonObject.get("Tags");
Iterator iterator = tag.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
I would like to get the console output to be as follows:
1 1 1 1 1 1 1 1
1 1 O O O O 1 1
1 1 O O O O 1 1
O 1 1 O O 1 1 O
O O 1 1 1 1 O O
O O 1 1 1 1 O O