use of json.JSONArray in project IR_Base by Linda-sunshine.
the class ParentChildAnalyzer method loadParentDoc.
public void loadParentDoc(String fileName) {
if (fileName == null || fileName.isEmpty())
return;
JSONObject json = LoadJSON(fileName);
String title = Utils.getJSONValue(json, "title");
String content = Utils.getJSONValue(json, "content");
String name = Utils.getJSONValue(json, "name");
String[] sentences = null;
// _ParentDoc d = new _ParentDoc(m_corpus.getSize(), name, title,
// content, 0);
_ParentDoc d = new _ParentDoc4DCM(m_corpus.getSize(), name, title, content, 0);
try {
JSONArray sentenceArray = json.getJSONArray("sentences");
sentences = new String[sentenceArray.length()];
// shall we add title into this sentence array
for (int i = 0; i < sentenceArray.length(); i++) sentences[i] = Utils.getJSONValue(sentenceArray.getJSONObject(i), "sentence");
if (AnalyzeDocByStn(d, sentences))
parentHashMap.put(name, d);
} catch (JSONException e) {
e.printStackTrace();
}
}
use of json.JSONArray in project JsonPath by json-path.
the class TapestryJsonProvider method setArrayIndex.
@Override
public void setArrayIndex(final Object array, final int index, final Object newValue) {
Object v = newValue == null ? JSONObject.NULL : newValue;
JSONArray list = (JSONArray) array;
list.put(index, v);
}
use of json.JSONArray in project JsonPath by json-path.
the class TapestryJsonProviderTest method a_filter_can_be_applied.
@Test
public void a_filter_can_be_applied() {
JSONArray fictionBooks = using(TAPESTRY_JSON_CONFIGURATION).parse(JSON_DOCUMENT).read("$.store.book[?(@.category == 'fiction')]");
assertThat(fictionBooks.length()).isEqualTo(3);
}
Aggregations