use of org.eclipse.leshan.json.LwM2mJsonException in project leshan by eclipse.
the class LwM2mNodeJsonDecoder method decode.
@SuppressWarnings("unchecked")
public static <T extends LwM2mNode> T decode(byte[] content, LwM2mPath path, LwM2mModel model, Class<T> nodeClass) throws CodecException {
try {
String jsonStrValue = content != null ? new String(content) : "";
JsonRootObject json = LwM2mJson.fromJsonLwM2m(jsonStrValue);
List<TimestampedLwM2mNode> timestampedNodes = parseJSON(json, path, model, nodeClass);
if (timestampedNodes.size() == 0) {
return null;
} else {
// return the most recent value
return (T) timestampedNodes.get(0).getNode();
}
} catch (LwM2mJsonException e) {
throw new CodecException(e, "Unable to deserialize json [path:%s]", path);
}
}
use of org.eclipse.leshan.json.LwM2mJsonException in project leshan by eclipse.
the class LwM2mNodeJsonDecoder method decodeTimestamped.
public static List<TimestampedLwM2mNode> decodeTimestamped(byte[] content, LwM2mPath path, LwM2mModel model, Class<? extends LwM2mNode> nodeClass) throws CodecException {
try {
String jsonStrValue = new String(content);
JsonRootObject json = LwM2mJson.fromJsonLwM2m(jsonStrValue);
return parseJSON(json, path, model, nodeClass);
} catch (LwM2mJsonException e) {
throw new CodecException(e, "Unable to deserialize json [path:%s]", path);
}
}
Aggregations