Package com.alibaba.fastjson.serializer
Class JavaBeanSerializer
- java.lang.Object
-
- com.alibaba.fastjson.serializer.SerializeFilterable
-
- com.alibaba.fastjson.serializer.JavaBeanSerializer
-
- All Implemented Interfaces:
ObjectSerializer
public class JavaBeanSerializer extends SerializeFilterable implements ObjectSerializer
- Author:
- wenshao[szujobs@hotmail.com]
-
-
Constructor Summary
Constructors Constructor Description JavaBeanSerializer(SerializeBeanInfo beanInfo)JavaBeanSerializer(Class<?> beanType)JavaBeanSerializer(Class<?> beanType, String... aliasList)JavaBeanSerializer(Class<?> beanType, Map<String,String> aliasMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>getFieldNames(Object object)Get field names of not null fields.FieldSerializergetFieldSerializer(long hash)FieldSerializergetFieldSerializer(String key)ObjectgetFieldValue(Object object, String key)ObjectgetFieldValue(Object object, String key, long keyHash, boolean throwFieldNotFoundException)List<Object>getFieldValues(Object object)Map<String,Object>getFieldValuesMap(Object object)JSONTypegetJSONType()List<Object>getObjectFieldValues(Object object)intgetSize(Object object)Class<?>getType()voidwrite(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)fastjson invokes this call-back method during serialization when it encounters a field of the specified type.voidwriteAsArray(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)voidwriteAsArrayNonContext(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)voidwriteDirectNonContext(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)voidwriteNoneASM(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)booleanwriteReference(JSONSerializer serializer, Object object, int fieldFeatures)-
Methods inherited from class com.alibaba.fastjson.serializer.SerializeFilterable
addFilter, apply, applyName, getAfterFilters, getBeforeFilters, getContextValueFilters, getLabelFilters, getNameFilters, getPropertyFilters, getPropertyPreFilters, getValueFilters
-
-
-
-
Constructor Detail
-
JavaBeanSerializer
public JavaBeanSerializer(Class<?> beanType)
-
JavaBeanSerializer
public JavaBeanSerializer(SerializeBeanInfo beanInfo)
-
-
Method Detail
-
getJSONType
public JSONType getJSONType()
-
getType
public Class<?> getType()
- Since:
- 1.2.42
-
writeDirectNonContext
public void writeDirectNonContext(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException
- Throws:
IOException
-
writeAsArray
public void writeAsArray(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException
- Throws:
IOException
-
writeAsArrayNonContext
public void writeAsArrayNonContext(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException
- Throws:
IOException
-
write
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException
Description copied from interface:ObjectSerializerfastjson invokes this call-back method during serialization when it encounters a field of the specified type.- Specified by:
writein interfaceObjectSerializerobject- src the object that needs to be converted to Json.fieldName- parent object field namefieldType- parent object field typefeatures- parent object field serializer features- Throws:
IOException
-
writeNoneASM
public void writeNoneASM(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException
- Throws:
IOException
-
writeReference
public boolean writeReference(JSONSerializer serializer, Object object, int fieldFeatures)
-
getFieldValue
public Object getFieldValue(Object object, String key, long keyHash, boolean throwFieldNotFoundException)
-
getFieldSerializer
public FieldSerializer getFieldSerializer(String key)
-
getFieldSerializer
public FieldSerializer getFieldSerializer(long hash)
-
getFieldValues
public List<Object> getFieldValues(Object object) throws Exception
- Throws:
Exception
-
getObjectFieldValues
public List<Object> getObjectFieldValues(Object object) throws Exception
- Throws:
Exception
-
getFieldNames
public Set<String> getFieldNames(Object object) throws Exception
Get field names of not null fields. Keep the same logic as getSize.- Parameters:
object- the object to be checked- Returns:
- field name set
- Throws:
Exception- See Also:
getSize(Object)
-
-