Added function to convert to JSONObject at ReceivedData class.

This commit is contained in:
WickedJack99
2024-04-07 11:55:52 +02:00
parent 33ea792d5e
commit e647f69acb

View File

@@ -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;
}
}