json.put(ENTITY_NAME, entity.getJsniSignature());
return json;
}
public static JSONObject writeJson(PackageDescriptor pkg) throws JSONException {
JSONObject json = new JSONObject();
json.put(ENTITY_NAME, pkg.getName());
// classes
JSONArray classes = new JSONArray();
for (ClassDescriptor classDescriptor : pkg.getClasses()) {
JSONObject jsonClass = writeJsonFromEntity(classDescriptor);
jsonClass.put(ENTITY_NAME, classDescriptor.getName());
// fields
JSONArray fields = new JSONArray();
for (FieldDescriptor fieldDescriptor : classDescriptor.getFields()) {
fields.put(writeJsonFromMember(fieldDescriptor));
}
jsonClass.put(FIELDS, fields);
// methods
JSONArray methods = new JSONArray();
for (MethodDescriptor methodDescriptor : classDescriptor.getMethods()) {
JSONObject jsonMethod = writeJsonFromMember(methodDescriptor);
jsonMethod.put(METHOD_ID, methodDescriptor.getUniqueId());
jsonMethod.put(METHOD_DEPENDENTS, new JSONArray(methodDescriptor.getDependentPointers()));
methods.put(jsonMethod);
}
jsonClass.put(METHODS, methods);
classes.put(jsonClass);