public void process(FeedExchange exchange) throws Exception {
List<BasicDBObject> collectionAttributes = (List<BasicDBObject>) exchange.getInput();
for (BasicDBObject collectionAttribute : collectionAttributes) {
if (collectionAttribute.get("name") != null) {
String attributeName = collectionAttribute.getString("name");
if (attributeName.equals(JobParamConstants.DEFAULT_LOCALE) || attributeName
.equals(JobParamConstants.APPLICABLE_LOCALES)) {
exchange.setProperty(attributeName, collectionAttribute.getString("_id"));
}
}
hi i need to write junit testcase for above program..so i want to pass input to collectionAttributes.my input json is GetCatalogCollectionResponse.json
{
"properties":[{
"attributeId":"123",
"value":"345"
},
{
"attributeId":"2345",
"value":"567"
}]
}
i want to parse this json to collectionAttributes in mongodb.i tried the following code
BasicDBObject DBObject = new BasicDBObject();
DBObject.parse(GetCatalogCollectionResponse.json);
but i got an error.could you help me i am beginner to java,any help would be appreciated..
DBObject.parseis used to parse a JSON string.