Reputation: 2159
I use the library json-simple.
Object is created in a simple loop (cinema.start(i, j)
returns a valid JSON-Object):
JSONObject cinemaJSON = null;
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 3; j++) {
if (cinema.start(i, j) != null)
cinemaJSON = cinema.start(i, j);
}
}
Then I try to merge two JSON-Objects and print it (cinema2.start("value")
returns a valid object, too):
System.out.println(cinemaJSON.putAll(cinema2.start("value")));
And at this point I get the error: 'void' type not allowed here
Are there ways to alternative implementation of my code to make it possible to display the result of the merger of two objects?
Thanks.
Upvotes: 0
Views: 222
Reputation: 68715
JSONObject putAll returns void
and hence sysout statement complains for it.
Just split the statement
System.out.println(cinemaJSON.putAll(cinema2.start("value")));
into two:
cinemaJSON.putAll(cinema2.start("value"));
System.out.println(cinemaJSON);
Upvotes: 2
Reputation: 35557
putAll()
is a void
method(nothing return). So you can try this way
cinemaJSON.putAll(cinema2.start("value"))
Now print
System.out.println(cinemaJSON);
Upvotes: 4