Added function to convert to JSONObject at ReceivedData class.
This commit is contained in:
@@ -4,4 +4,20 @@
|
||||
|
||||
package vslab1.src.Receiving;
|
||||
|
||||
public record ReceivedData(String data) {}
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public record ReceivedData(String data) {
|
||||
|
||||
public JSONObject interpretAsJSONObject() {
|
||||
try {
|
||||
JSONObject receivedDataAsJSONObject = null;
|
||||
receivedDataAsJSONObject = new JSONObject(data);
|
||||
return receivedDataAsJSONObject;
|
||||
} catch (JSONException e) {
|
||||
System.out.println(data);
|
||||
System.err.println("File is a json file, not able to parse it.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user