source: AE/installer2/src/net/oni2/aeinstaller/backend/depot/JSONHelpers.java@ 592

Last change on this file since 592 was 591, checked in by alloc, 12 years ago

AEI2-import

File size: 680 bytes
Line 
1package net.oni2.aeinstaller.backend.depot;
2
3import org.json.JSONException;
4import org.json.JSONObject;
5
6/**
7 * @author Christian Illy
8 */
9public class JSONHelpers {
10 /**
11 * Return the string associated with the given key or null if the key does
12 * not exist or does not contain a string
13 *
14 * @param parent
15 * Parent JSON object
16 * @param key
17 * Key to look for
18 * @return Contained string or null
19 */
20 public static String getStringOrNull(JSONObject parent, String key) {
21 try {
22 Object obj = parent.get(key);
23 if (obj instanceof String)
24 return (String) obj;
25 } catch (JSONException e) {
26 e.printStackTrace();
27 }
28 return null;
29 }
30}
Note: See TracBrowser for help on using the repository browser.