Replace tabs with spaces

master
Stuart Boston 10 years ago
parent d8e56616e8
commit e95b76c44a

@ -8,5 +8,6 @@ import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface JsonProperty { public @interface JsonProperty {
String value() default ""; String value() default "";
} }

@ -12,23 +12,23 @@ import org.json.JSONObject;
public class ObjectMapper { public class ObjectMapper {
/** /**
* This takes a JSON string and creates (and populates) an object of the given class * This takes a JSON string and creates (and populates) an object of the
* with the data from that JSON string. It mimics the method signature of the jackson * given class with the data from that JSON string. It mimics the method
* JSON API, so that we don't have to import the jackson library into this application. * signature of the jackson JSON API, so that we don't have to import the
* jackson library into this application.
* *
* @param jsonString The JSON string to parse. * @param jsonString The JSON string to parse.
* @param objClass The class of object we want to create. * @param objClass The class of object we want to create.
* @return The instantiation of that class, populated with data from the JSON object. * @return The instantiation of that class, populated with data from the
* JSON object.
* @throws IOException If there was any kind of issue. * @throws IOException If there was any kind of issue.
*/ */
public <T> T readValue(String jsonString, Class<T> objClass) throws IOException { public <T> T readValue(String jsonString, Class<T> objClass) throws IOException {
try { try {
return readValue(new JSONObject(jsonString), objClass); return readValue(new JSONObject(jsonString), objClass);
} } catch (IOException ioe) {
catch (IOException ioe) {
throw ioe; throw ioe;
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new IOException(e); throw new IOException(e);
} }
@ -50,17 +50,14 @@ public class ObjectMapper {
subObjList.add((R) readValue(jsonArray.getJSONObject(i), subObj)); subObjList.add((R) readValue(jsonArray.getJSONObject(i), subObj));
} }
f.set(obj, subObjList); f.set(obj, subObjList);
} } else if (a != null) {
else if (a != null) {
f.set(obj, json.opt(((JsonProperty) a).value())); f.set(obj, json.opt(((JsonProperty) a).value()));
} }
} }
return obj; return obj;
} } catch (IOException ioe) {
catch (IOException ioe) {
throw ioe; throw ioe;
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new IOException(e); throw new IOException(e);
} }

Loading…
Cancel
Save