Click here to Skip to main content
16,017,650 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to read Json Array file and pass it as a function arguments for testing the function n java

here i need to pass the properties argument to the below function.
my function is below:
public static void convertDateAttrsToString(JSONArray properties, BasicDBObject attributesObj) {
if (properties != null && !properties.isEmpty()) {
for (Object property1 : properties) {
JSONObject property = (JSONObject) property1;
if (attributesObj.containsField(attributeId)) {
BasicDBObject attribute = (BasicDBObject) attributesObj.get(attributeId);
if (attribute.getString(Constants.CONSTANT_DATATYPE).equals(Constants.CONSTANT_DATE)) {
property.put(attributeId, convertToLocalDateTimeViaInstant((Date) property.get("value")));
}
}
}
}
}


my json array file is JsonArray.json

{
"name":"John",
"age":30,
"cars":[ "Ford", "BMW", "Fiat" ]
}

What I have tried:

URL resource = App.class.getClassLoader().getResource("JsonArray.json")
String json = resource.toString();
FileReader reader = new FileReader(resource.getFile());

// Read JSON file
Object obj = JsonParser.parseList();

JSONArray infoList = (JSONArray) obj;

it shows error .anyhelp wouldbe appreciated
Posted
Comments
Richard MacCutchan 21-Oct-20 4:03am    
"it shows error "
Please explain what error and where it occurs.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900