I have a JSON question.
The following code is where the error occurs. I have verified the result string is the following.
{"name":"test", "num1":1.0, "num2":2.0}
and this is the code.
byte[] raw = new byte[1536];
try{
DatagramPacket packet = new DatagramPacket( raw, raw.length );
mSocket.receive( packet ); //Multicast Socket declared in another part of the program
String result = new String(packet.getData(), 0, packet.getLength());
JSONObject jObj = new JSONObject(result);
String name = jObj.getString("name");
}
catch (JSONException e){
}
catch(Exception eX){
}
However I get a JSONException with the following error.
No value for name.
Is there something wrong with my JSON syntax?
Thanks,


It looks like there is an issue with the encoding. Have you tried specifying UTF-8
I’m not sure what the issue could be. The rest of your code looks correct.