Skip to content

Commit

Permalink
Replace the deprecated use of new JsonParser with the use of its stat…
Browse files Browse the repository at this point in the history
…ic methods
  • Loading branch information
panic08 committed Dec 19, 2024
1 parent ffc847f commit 280318a
Show file tree
Hide file tree
Showing 928 changed files with 2,778 additions and 4,903 deletions.
8 changes: 3 additions & 5 deletions src/main/java/com/facebook/ads/sdk/ALMAdAccountInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ public String getId() {
public static ALMAdAccountInfo loadJSON(String json, APIContext context, String header) {
ALMAdAccountInfo almAdAccountInfo = getGson().fromJson(json, ALMAdAccountInfo.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(almAdAccountInfo.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(almAdAccountInfo.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -151,10 +150,9 @@ public static APINodeList<ALMAdAccountInfo> parseResponse(String json, APIContex
APINodeList<ALMAdAccountInfo> almAdAccountInfos = new APINodeList<ALMAdAccountInfo>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/facebook/ads/sdk/ALMEndAdvertiserInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ public String getId() {
public static ALMEndAdvertiserInfo loadJSON(String json, APIContext context, String header) {
ALMEndAdvertiserInfo almEndAdvertiserInfo = getGson().fromJson(json, ALMEndAdvertiserInfo.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(almEndAdvertiserInfo.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(almEndAdvertiserInfo.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -143,10 +142,9 @@ public static APINodeList<ALMEndAdvertiserInfo> parseResponse(String json, APICo
APINodeList<ALMEndAdvertiserInfo> almEndAdvertiserInfos = new APINodeList<ALMEndAdvertiserInfo>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/facebook/ads/sdk/ALMEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ public String getId() {
public static ALMEvent loadJSON(String json, APIContext context, String header) {
ALMEvent almEvent = getGson().fromJson(json, ALMEvent.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(almEvent.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(almEvent.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -157,10 +156,9 @@ public static APINodeList<ALMEvent> parseResponse(String json, APIContext contex
APINodeList<ALMEvent> almEvents = new APINodeList<ALMEvent>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/facebook/ads/sdk/ALMGuidance.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ public String getId() {
public static ALMGuidance loadJSON(String json, APIContext context, String header) {
ALMGuidance almGuidance = getGson().fromJson(json, ALMGuidance.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(almGuidance.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(almGuidance.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -82,10 +81,9 @@ public static APINodeList<ALMGuidance> parseResponse(String json, APIContext con
APINodeList<ALMGuidance> almGuidances = new APINodeList<ALMGuidance>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/facebook/ads/sdk/ALMGuidanceMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ public String getId() {
public static ALMGuidanceMetrics loadJSON(String json, APIContext context, String header) {
ALMGuidanceMetrics almGuidanceMetrics = getGson().fromJson(json, ALMGuidanceMetrics.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(almGuidanceMetrics.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(almGuidanceMetrics.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -100,10 +99,9 @@ public static APINodeList<ALMGuidanceMetrics> parseResponse(String json, APICont
APINodeList<ALMGuidanceMetrics> almGuidanceMetricss = new APINodeList<ALMGuidanceMetrics>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/facebook/ads/sdk/AMOneshopSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ public String getId() {
public static AMOneshopSettings loadJSON(String json, APIContext context, String header) {
AMOneshopSettings amOneshopSettings = getGson().fromJson(json, AMOneshopSettings.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(amOneshopSettings.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(amOneshopSettings.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -74,10 +73,9 @@ public static APINodeList<AMOneshopSettings> parseResponse(String json, APIConte
APINodeList<AMOneshopSettings> amOneshopSettingss = new APINodeList<AMOneshopSettings>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/facebook/ads/sdk/ANBlockedBICategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ public String getId() {
public static ANBlockedBICategory loadJSON(String json, APIContext context, String header) {
ANBlockedBICategory anBlockedBICategory = getGson().fromJson(json, ANBlockedBICategory.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(anBlockedBICategory.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(anBlockedBICategory.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -76,10 +75,9 @@ public static APINodeList<ANBlockedBICategory> parseResponse(String json, APICon
APINodeList<ANBlockedBICategory> anBlockedBICategorys = new APINodeList<ANBlockedBICategory>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/facebook/ads/sdk/APIContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ public String getAppID() {
params.put("fields", "app_id");

APIRequest.ResponseWrapper response = executor.execute("GET", apiUrl, params, this);
JsonParser parser = new JsonParser();
this.appID = parser.parse(response.getBody())
this.appID = JsonParser.parseString(response.getBody())
.getAsJsonObject()
.get("data")
.getAsJsonObject()
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/facebook/ads/sdk/APIException.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public String getRawResponse() {

@Override
public JsonObject getRawResponseAsJsonObject() {
JsonParser parser = new JsonParser();
return parser.parse(this.getMessage()).getAsJsonObject();
return JsonParser.parseString(this.getMessage()).getAsJsonObject();
}

@Override
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/com/facebook/ads/sdk/APINode.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public String toString() {

public String getId() {
try {
JsonParser parser = new JsonParser();
return parser.parse(rawValue).getAsJsonObject().get("id").getAsString();
return JsonParser.parseString(rawValue).getAsJsonObject().get("id").getAsString();
} catch (Exception e) {
return null;
}
Expand All @@ -81,9 +80,8 @@ public String getRawResponse() {

@Override
public JsonObject getRawResponseAsJsonObject() {
JsonParser parser = new JsonParser();
try {
return parser.parse(rawValue).getAsJsonObject();
return JsonParser.parseString(rawValue).getAsJsonObject();
} catch (Exception e) {
return null;
}
Expand All @@ -103,10 +101,9 @@ public static APINodeList<APINode> parseResponse(String json, APIContext context
APINodeList<APINode> nodes = new APINodeList<APINode>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/facebook/ads/sdk/APINodeList.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ public String getRawResponse() {

@Override
public JsonObject getRawResponseAsJsonObject() {
JsonParser parser = new JsonParser();
return parser.parse(rawValue).getAsJsonObject();
return JsonParser.parseString(rawValue).getAsJsonObject();
}

@Override
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/facebook/ads/sdk/AREffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ public String getId() {
public static AREffect loadJSON(String json, APIContext context, String header) {
AREffect arEffect = getGson().fromJson(json, AREffect.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(arEffect.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(arEffect.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -145,10 +144,9 @@ public static APINodeList<AREffect> parseResponse(String json, APIContext contex
APINodeList<AREffect> arEffects = new APINodeList<AREffect>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/facebook/ads/sdk/Ad.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,8 @@ public String getId() {
public static Ad loadJSON(String json, APIContext context, String header) {
Ad ad = getGson().fromJson(json, Ad.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(ad.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(ad.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -211,10 +210,9 @@ public static APINodeList<Ad> parseResponse(String json, APIContext context, API
APINodeList<Ad> ads = new APINodeList<Ad>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/com/facebook/ads/sdk/AdAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,8 @@ public String getId() {
public static AdAccount loadJSON(String json, APIContext context, String header) {
AdAccount adAccount = getGson().fromJson(json, AdAccount.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(adAccount.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(adAccount.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -269,8 +268,7 @@ public static AdAccount loadJSON(String json, APIContext context, String header)
adAccount.context = context;
adAccount.rawValue = json;
adAccount.header = header;
JsonParser parser = new JsonParser();
JsonObject o = parser.parse(json).getAsJsonObject();
JsonObject o = JsonParser.parseString(json).getAsJsonObject();
if (o.has("account_id")) {
String accountId = o.get("account_id").getAsString();
if (accountId != null) {
Expand All @@ -287,10 +285,9 @@ public static APINodeList<AdAccount> parseResponse(String json, APIContext conte
APINodeList<AdAccount> adAccounts = new APINodeList<AdAccount>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ public String getId() {
public static AdAccountAAACompatibleAdObjects loadJSON(String json, APIContext context, String header) {
AdAccountAAACompatibleAdObjects adAccountAAACompatibleAdObjects = getGson().fromJson(json, AdAccountAAACompatibleAdObjects.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(adAccountAAACompatibleAdObjects.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(adAccountAAACompatibleAdObjects.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -80,10 +79,9 @@ public static APINodeList<AdAccountAAACompatibleAdObjects> parseResponse(String
APINodeList<AdAccountAAACompatibleAdObjects> adAccountAAACompatibleAdObjectss = new APINodeList<AdAccountAAACompatibleAdObjects>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ public String getId() {
public static AdAccountAAASimilarCampaigns loadJSON(String json, APIContext context, String header) {
AdAccountAAASimilarCampaigns adAccountAAASimilarCampaigns = getGson().fromJson(json, AdAccountAAASimilarCampaigns.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(adAccountAAASimilarCampaigns.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(adAccountAAASimilarCampaigns.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -80,10 +79,9 @@ public static APINodeList<AdAccountAAASimilarCampaigns> parseResponse(String jso
APINodeList<AdAccountAAASimilarCampaigns> adAccountAAASimilarCampaignss = new APINodeList<AdAccountAAASimilarCampaigns>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/facebook/ads/sdk/AdAccountASLSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ public String getId() {
public static AdAccountASLSchedule loadJSON(String json, APIContext context, String header) {
AdAccountASLSchedule adAccountASLSchedule = getGson().fromJson(json, AdAccountASLSchedule.class);
if (context.isDebug()) {
JsonParser parser = new JsonParser();
JsonElement o1 = parser.parse(json);
JsonElement o2 = parser.parse(adAccountASLSchedule.toString());
JsonElement o1 = JsonParser.parseString(json);
JsonElement o2 = JsonParser.parseString(adAccountASLSchedule.toString());
if (o1.getAsJsonObject().get("__fb_trace_id__") != null) {
o2.getAsJsonObject().add("__fb_trace_id__", o1.getAsJsonObject().get("__fb_trace_id__"));
}
Expand All @@ -82,10 +81,9 @@ public static APINodeList<AdAccountASLSchedule> parseResponse(String json, APICo
APINodeList<AdAccountASLSchedule> adAccountASLSchedules = new APINodeList<AdAccountASLSchedule>(request, json, header);
JsonArray arr;
JsonObject obj;
JsonParser parser = new JsonParser();
Exception exception = null;
try{
JsonElement result = parser.parse(json);
JsonElement result = JsonParser.parseString(json);
if (result.isJsonArray()) {
// First, check if it's a pure JSON Array
arr = result.getAsJsonArray();
Expand Down
Loading

0 comments on commit 280318a

Please sign in to comment.