Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
ncvp13
ncvp13's Profile
2
Posts
5
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Client output property
[2 Replies]
29-Jun-2013 03:39 AM
Forum:
Programming Questions
I've inherited some code:
Client socket;
...
socket = new Client(papplet, host, port);
...
if (socket.output != null)
...
I can't find anything about .output in the documentation, and it's not clear to me in the code what aspect of the socket is being checked.
Can anyone explain, please?
JSON: Checking for existence of things
[9 Replies]
28-Jun-2013 02:17 PM
Forum:
Contributed Library Questions
If I know a certain key (?terminology) exists in a JSON object I can get it without problems:
import org.json.*;
JSON job1 = JSON.parse(playlist_rx);
JSON job2 = job1.getObject("result");
JSON job3 = job2.getArray("items");
...
but what if I don't know if job1 has got a "result"?
If I go ahead and say
JSON job2 = job1.getObject("result");
and there isn't one, an exception is thrown. So I have to code like this:
try
{
JSON job2 = job1.getObject("result");
}
catch (Exception E)
{
Oh, it doesn't have a "result", it must be one of the other sorts
}
which degenerates into a horrible mess becasue I'm expecting 3 or 4 different JSON responses.
Is there any way of checking this sort of thing without throwing exceptions?
«Prev
Next »
Moderate user : ncvp13
Forum