19 package org.sleuthkit.datamodel.blackboardutils.attributes;
21 import com.google.gson.Gson;
22 import com.google.gson.JsonSyntaxException;
46 throw new IllegalArgumentException(String.format(
"Attribute type %s does not have value type BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.JSON", attrType.getTypeName()));
70 throw new IllegalArgumentException(String.format(
"Attribute type %s does not have value type BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.JSON", attrType.getTypeName()));
72 String json = attr.getValueString();
73 if (json == null || json.isEmpty()) {
77 return (
new Gson()).fromJson(json, clazz);
78 }
catch (JsonSyntaxException ex) {
79 throw new InvalidJsonException(String.format(
"The string value (JSON) could not be deserialized as a %s", clazz.getName()), ex);
89 private static final long serialVersionUID = 1L;
109 super(message, cause);
static< T > BlackboardAttribute toAttribute(BlackboardAttribute.Type attrType, String moduleName, T attrValue)
static< T > T fromAttribute(BlackboardAttribute attr, Class< T > clazz)
InvalidJsonException(String message, Throwable cause)
InvalidJsonException(String message)