@@ -203,15 +203,22 @@ private void getService(String requestUrl) throws IOException {
203203
204204
205205 void handleJSONArray () {
206- JSONArray entries = new JSONArray ();
207206 if (responseJSON .has ("entries" ) && !responseJSON .optJSONArray ("entries" ).isEmpty ()) {
208- entries = responseJSON .optJSONArray ("entries" );
207+ JSONArray finalEntries = responseJSON .optJSONArray ("entries" );
208+ IntStream .range (0 , finalEntries .length ()).forEach (idx -> {
209+ JSONObject objJSON = (JSONObject ) finalEntries .get (idx );
210+ handleJSONObject (finalEntries , objJSON , idx );
211+ });
209212 }
210- JSONArray finalEntries = entries ;
211- IntStream .range (0 , entries .length ()).forEach (idx -> {
212- JSONObject objJSON = (JSONObject ) finalEntries .get (idx );
213- handleJSONObject (finalEntries , objJSON , idx );
214- });
213+ if (responseJSON .has ("entry" ) && !responseJSON .optJSONObject ("entry" ).isEmpty ()) {
214+ JSONObject entry = responseJSON .optJSONObject ("entry" );
215+ if (!entry .isEmpty ()) {
216+ if (entry .has ("uid" ) && entry .opt ("uid" ).equals (this .config .livePreviewEntry .opt ("uid" ))) {
217+ responseJSON = new JSONObject ().put ("entry" , this .config .livePreviewEntry );
218+ }
219+ }
220+ }
221+
215222 }
216223
217224 void handleJSONObject (JSONArray arrayEntry , JSONObject jsonObj , int idx ) {
@@ -223,23 +230,6 @@ void handleJSONObject(JSONArray arrayEntry, JSONObject jsonObj, int idx) {
223230 responseJSON = new JSONObject ().put ("entries" , arrayEntry );
224231 }
225232
226- private void deepMergeElse (JSONArray arrayEntry , JSONObject jsonObj , int idx ) {
227-
228- do {
229- String k = jsonObj .keySet ().iterator ().next ();
230- if (jsonObj .opt (k ) instanceof JSONArray ) {
231- JSONArray subArray = (JSONArray ) jsonObj .opt (k );
232- IntStream .range (0 , subArray .length ()).forEach (pos -> {
233- JSONObject objJSON = (JSONObject ) subArray .get (pos );
234- handleJSONObject (subArray , objJSON , pos );
235- });
236- }
237- if (jsonObj .opt (k ) instanceof JSONObject ) {
238- handleJSONObject (arrayEntry , ((JSONObject ) jsonObj .opt (k )), idx );
239- }
240- } while (jsonObj .keySet ().iterator ().hasNext ());
241- }
242-
243233
244234 void setError (String errResp ) {
245235 logger .info (errResp );
0 commit comments