	private JSONObject processElement(CRResolvableBean crBean) {
		JSONObject objElement = new JSONObject();
		objElement.element("contentid", "" + crBean.getContentid());
		objElement.element("obj_id", "" + crBean.getObj_id());
		objElement.element("obj_type", "" + crBean.getObj_type());
		objElement.element("mother_id",
				((crBean.getMother_id() == null) ? "" : ""
						+ crBean.getMother_id()));
		objElement.element("mother_type",
				((crBean.getMother_type() == null) ? "" : ""
						+ crBean.getMother_type()));
		if (crBean.getAttrMap() != null && (!crBean.getAttrMap().isEmpty())) {
			JSONObject attrContainer = new JSONObject();
			Iterator<String> bit = crBean.getAttrMap().keySet().iterator();
			while (bit.hasNext()) {
				String entry = bit.next();
				Object bValue=crBean.getAttrMap().get(entry);
				if(bValue!=null)
				{
					if((!entry.equals("binarycontent")) &&(bValue.getClass().isArray()||bValue.getClass()==ArrayList.class))
					{
						JSONArray value = new JSONArray();
						ArrayList<Object> arr;
						if(bValue.getClass()==ArrayList.class)
							arr=(ArrayList<Object>)bValue;
						else
						{
							arr=new ArrayList<Object>();
							Object[] ob_arr = (Object[])bValue;
							for(int i=0;i<ob_arr.length;i++ )
								arr.add(ob_arr[i]);
						}
						value.addAll(arr);
						attrContainer.element(entry, value);
					}
					else
					{
						String value="";
						if(entry.equals("binarycontent"))
						{
							byte[] bs = (byte[])bValue;
							value=new String(bs);
						}
						else
						{
							if(bValue.getClass()==String.class)
							{
								value=(String)bValue;
							}
							else
							{
								try {
									value = new String(getBytes(bValue));
								} catch (IOException e) {
									e.printStackTrace();
								}
							}
						}
						attrContainer.element(entry, value);
					}
				}
			}
			objElement.element("attributes",attrContainer);
		}
		if(crBean.getChildRepository() != null && crBean.getChildRepository().size()>0)
		{
			JSONArray childContainer = new JSONArray();
			for (Iterator it = crBean.getChildRepository().iterator(); it.hasNext();) {
				CRResolvableBean chBean = (CRResolvableBean) it.next();
				JSONObject chElement = processElement(chBean);
				childContainer.add(chElement);
			}
			objElement.element("children",childContainer);
		}
		return objElement;
	}

	private JSONObject processElement(CRResolvableBean crBean) {
		JSONObject objElement = new JSONObject();
		objElement.element("contentid", "" + crBean.getContentid());
		objElement.element("obj_id", "" + crBean.getObj_id());
		objElement.element("obj_type", "" + crBean.getObj_type());
		objElement.element("mother_id",
				((crBean.getMother_id() == null) ? "" : ""
						+ crBean.getMother_id()));
		objElement.element("mother_type",
				((crBean.getMother_type() == null) ? "" : ""
						+ crBean.getMother_type()));
		if (crBean.getAttrMap() != null && (!crBean.getAttrMap().isEmpty())) {
			JSONObject attrContainer = new JSONObject();
			Iterator<String> bit = crBean.getAttrMap().keySet().iterator();
			while (bit.hasNext()) {
				String entry = bit.next();
				Object bValue=crBean.getAttrMap().get(entry);
				if(bValue!=null)
				{
					if((!entry.equals("binarycontent")) &&(bValue.getClass().isArray()||bValue.getClass()==ArrayList.class))
					{
						JSONArray value = new JSONArray();
						ArrayList<Object> arr;
						if(bValue.getClass()==ArrayList.class)
							arr=(ArrayList<Object>)bValue;
						else
						{
							arr=new ArrayList<Object>();
							Object[] ob_arr = (Object[])bValue;
							for(int i=0;i<ob_arr.length;i++ )
								arr.add(ob_arr[i]);
						}
						value.addAll(arr);
						attrContainer.element(entry, value);
					}
					else
					{
						String value="";
						if(entry.equals("binarycontent"))
						{
							byte[] bs = (byte[])bValue;
							value=new String(bs);
						}
						else
						{
							if(bValue.getClass()==String.class)
							{
								value=(String)bValue;
							} else if (bValue instanceof Number) {
								value = bValue.toString();
							} else {
								try {
									value = new String(getBytes(bValue));
								} catch (IOException e) {
									e.printStackTrace();
								}
							}
						}
						attrContainer.element(entry, value);
					}
				}
			}
			objElement.element("attributes",attrContainer);
		}
		if(crBean.getChildRepository() != null && crBean.getChildRepository().size()>0)
		{
			JSONArray childContainer = new JSONArray();
			for (Iterator it = crBean.getChildRepository().iterator(); it.hasNext();) {
				CRResolvableBean chBean = (CRResolvableBean) it.next();
				JSONObject chElement = processElement(chBean);
				childContainer.add(chElement);
			}
			objElement.element("children",childContainer);
		}
		return objElement;
	}
