21import java.lang.reflect.Type;
23import org.openscience.cdk.interfaces.IAtomContainer;
24import org.openscience.cdk.interfaces.IChemObjectBuilder;
25import org.openscience.cdk.silent.SilentChemObjectBuilder;
27import com.google.gson.JsonArray;
28import com.google.gson.JsonDeserializationContext;
29import com.google.gson.JsonDeserializer;
30import com.google.gson.JsonElement;
31import com.google.gson.JsonObject;
32import com.google.gson.JsonParseException;
45 private IChemObjectBuilder
builder = SilentChemObjectBuilder.getInstance();
48 public IAtomContainer
deserialize(JsonElement jsonEl, Type type,
49 JsonDeserializationContext context)
throws JsonParseException
51 JsonObject jo = jsonEl.getAsJsonObject();
56 IAtomContainer iac =
builder.newAtomContainer();
58 JsonArray atomArr = jo.get(
60 for (JsonElement e : atomArr)
66 JsonArray bondArr = jo.get(
68 for (JsonElement e : bondArr)
Deserialisation of collections of both light-weight atoms and bonds into a CDK IAtomContainer.
IChemObjectBuilder builder
IAtomContainer deserialize(JsonElement jsonEl, Type type, JsonDeserializationContext context)
Class to serialise CDK's IAtomContainer in a simplified manner.
static final String ATOMSKEY
String used to identify the list of atoms in json map.
static final String BONDSKEY
String used to identify the list of bonds in json map.
A light-weight atom representation to facilitate json serialization of IAtom.
IAtom toIAtom()
Returns a CDK representation of this center.
A light-weight bond representation to facilitate json serialization of IBond.
int[] atomIds
0-based index of the centers, i.e., atoms or pseudo-atoms, connected by this bond.
IBond.Order bo
Type of bond.