com.alibaba.fastjson.serializer.JavaBeanSerializer Java Examples
The following examples show how to use
com.alibaba.fastjson.serializer.JavaBeanSerializer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSONPath.java From uavstack with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) protected Collection<Object> getPropertyValues(final Object currentObject) { final Class<?> currentClass = currentObject.getClass(); JavaBeanSerializer beanSerializer = getJavaBeanSerializer(currentClass); if (beanSerializer != null) { try { return beanSerializer.getFieldValues(currentObject); } catch (Exception e) { throw new JSONPathException("jsonpath error, path " + path, e); } } if (currentObject instanceof Map) { Map map = (Map) currentObject; return map.values(); } throw new UnsupportedOperationException(); }
Example #2
Source File: JSONPath_s.java From coming with MIT License | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) protected Collection<Object> getPropertyValues(final Object currentObject) { final Class<?> currentClass = currentObject.getClass(); JavaBeanSerializer beanSerializer = getJavaBeanSerializer(currentClass); if (beanSerializer != null) { try { return beanSerializer.getFieldValues(currentObject); } catch (Exception e) { throw new JSONPathException("jsonpath error, path " + path, e); } } if (currentObject instanceof Map) { Map map = (Map) currentObject; return map.values(); } if (currentObject instanceof Collection) { return (Collection) currentObject; } throw new UnsupportedOperationException(); }
Example #3
Source File: JSONPath.java From uavstack with Apache License 2.0 | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) Set<?> evalKeySet(Object currentObject) { if (currentObject == null) { return null; } if (currentObject instanceof Map) { // For performance reasons return keySet directly, without filtering null-value key. return ((Map)currentObject).keySet(); } if (currentObject instanceof Collection || currentObject instanceof Object[] || currentObject.getClass().isArray()) { return null; } JavaBeanSerializer beanSerializer = getJavaBeanSerializer(currentObject.getClass()); if (beanSerializer == null) { return null; } try { return beanSerializer.getFieldNames(currentObject); } catch (Exception e) { throw new JSONPathException("evalKeySet error : " + path, e); } }
Example #4
Source File: JSONPath_s.java From coming with MIT License | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) Set<?> evalKeySet(Object currentObject) { if (currentObject == null) { return null; } if (currentObject instanceof Map) { // For performance reasons return keySet directly, without filtering null-value key. return ((Map)currentObject).keySet(); } if (currentObject instanceof Collection || currentObject instanceof Object[] || currentObject.getClass().isArray()) { return null; } JavaBeanSerializer beanSerializer = getJavaBeanSerializer(currentObject.getClass()); if (beanSerializer == null) { return null; } try { return beanSerializer.getFieldNames(currentObject); } catch (Exception e) { throw new JSONPathException("evalKeySet error : " + path, e); } }
Example #5
Source File: JSONPath_t.java From coming with MIT License | 5 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) protected Collection<Object> getPropertyValues(final Object currentObject) { if (currentObject == null) { return null; } final Class<?> currentClass = currentObject.getClass(); JavaBeanSerializer beanSerializer = getJavaBeanSerializer(currentClass); if (beanSerializer != null) { try { return beanSerializer.getFieldValues(currentObject); } catch (Exception e) { throw new JSONPathException("jsonpath error, path " + path, e); } } if (currentObject instanceof Map) { Map map = (Map) currentObject; return map.values(); } if (currentObject instanceof Collection) { return (Collection) currentObject; } throw new UnsupportedOperationException(); }
Example #6
Source File: JSONPath_t.java From coming with MIT License | 5 votes |
@SuppressWarnings({"rawtypes", "unchecked"}) Set<?> evalKeySet(Object currentObject) { if (currentObject == null) { return null; } if (currentObject instanceof Map) { // For performance reasons return keySet directly, without filtering null-value key. return ((Map)currentObject).keySet(); } if (currentObject instanceof Collection || currentObject instanceof Object[] || currentObject.getClass().isArray()) { return null; } JavaBeanSerializer beanSerializer = getJavaBeanSerializer(currentObject.getClass()); if (beanSerializer == null) { return null; } try { return beanSerializer.getFieldNames(currentObject); } catch (Exception e) { throw new JSONPathException("evalKeySet error : " + path, e); } }
Example #7
Source File: JSONPath.java From uavstack with Apache License 2.0 | 4 votes |
@SuppressWarnings("rawtypes") int evalSize(Object currentObject) { if (currentObject == null) { return -1; } if (currentObject instanceof Collection) { return ((Collection) currentObject).size(); } if (currentObject instanceof Object[]) { return ((Object[]) currentObject).length; } if (currentObject.getClass().isArray()) { return Array.getLength(currentObject); } if (currentObject instanceof Map) { int count = 0; for (Object value : ((Map) currentObject).values()) { if (value != null) { count++; } } return count; } JavaBeanSerializer beanSerializer = getJavaBeanSerializer(currentObject.getClass()); if (beanSerializer == null) { return -1; } try { return beanSerializer.getSize(currentObject); } catch (Exception e) { throw new JSONPathException("evalSize error : " + path, e); } }
Example #8
Source File: JSONPath_s.java From coming with MIT License | 4 votes |
@SuppressWarnings("rawtypes") int evalSize(Object currentObject) { if (currentObject == null) { return -1; } if (currentObject instanceof Collection) { return ((Collection) currentObject).size(); } if (currentObject instanceof Object[]) { return ((Object[]) currentObject).length; } if (currentObject.getClass().isArray()) { return Array.getLength(currentObject); } if (currentObject instanceof Map) { int count = 0; for (Object value : ((Map) currentObject).values()) { if (value != null) { count++; } } return count; } JavaBeanSerializer beanSerializer = getJavaBeanSerializer(currentObject.getClass()); if (beanSerializer == null) { return -1; } try { return beanSerializer.getSize(currentObject); } catch (Exception e) { throw new JSONPathException("evalSize error : " + path, e); } }
Example #9
Source File: JSONPath_t.java From coming with MIT License | 4 votes |
@SuppressWarnings("rawtypes") int evalSize(Object currentObject) { if (currentObject == null) { return -1; } if (currentObject instanceof Collection) { return ((Collection) currentObject).size(); } if (currentObject instanceof Object[]) { return ((Object[]) currentObject).length; } if (currentObject.getClass().isArray()) { return Array.getLength(currentObject); } if (currentObject instanceof Map) { int count = 0; for (Object value : ((Map) currentObject).values()) { if (value != null) { count++; } } return count; } JavaBeanSerializer beanSerializer = getJavaBeanSerializer(currentObject.getClass()); if (beanSerializer == null) { return -1; } try { return beanSerializer.getSize(currentObject); } catch (Exception e) { throw new JSONPathException("evalSize error : " + path, e); } }