In one of my libraries say libA, I am reading a JsonArray (with string values in it) from JsonObject and converting it to String[] before adding it to an intent as extra and then I pass down that intent to another activity say activityA. I am reading from intent in activityA and creating a JsonObject out of it for use later, but am not able to add an array directly to a JsonObject.
Code in libA:
JsonObject metadata; // This has the JsonArray in it.
final String[] bookIdsArray = new Gson().fromJson(metadata.get("bookIds") , String[].class);
testIntent.putExtra("bookIds", bookIdsArray);
Code in activityA:
final JsonObject activityMetadata = new JsonObject();
activityMetadata.addProperty("bookIds", String.valueOf(intent.getStringArrayExtra("bookIds")));
addProperty method of JsonObject only accepts String, Number, Boolean or Character and another method called 'add' only accepts JsonElement. How can I directly add array to it?