1
|
1 package de.mpiwg.itgroup.diva.utils;
|
|
2
|
|
3 import javax.ws.rs.WebApplicationException;
|
|
4 import javax.ws.rs.core.Response;
|
|
5 import javax.ws.rs.core.Response.Status;
|
|
6
|
|
7 import org.json.JSONArray;
|
|
8 import org.json.JSONException;
|
|
9
|
|
10 public class JSONArrayParam {
|
|
11
|
|
12 private JSONArray json;
|
|
13
|
|
14 public JSONArrayParam(String string) throws WebApplicationException {
|
|
15
|
|
16 try {
|
|
17 json = new JSONArray(string);
|
|
18 } catch (JSONException e) {
|
|
19 throw new WebApplicationException(Response.status(Status.BAD_REQUEST)
|
|
20 .entity("Couldn't parse JSON string: " + e.getMessage())
|
|
21 .build());
|
|
22 }
|
|
23 }
|
|
24
|
|
25 public JSONArray getArray() {
|
|
26 return json;
|
|
27 }
|
|
28 }
|