public JsonElement serialize()

in src/org/jetbrains/plugins/ipnb/format/IpnbParser.java [480:520]


    public JsonElement serialize(IpnbCellRaw cellRaw, Type typeOfSrc, JsonSerializationContext context) {
      final JsonObject jsonObject = new JsonObject();
      jsonObject.addProperty("cell_type", cellRaw.cell_type);
      if ("code".equals(cellRaw.cell_type)) {
        final Integer count = cellRaw.execution_count;
        if (count == null) {
          jsonObject.add("execution_count", JsonNull.INSTANCE);
        }
        else {
          jsonObject.addProperty("execution_count", count);
        }
      }
      if (cellRaw.metadata != null) {
        final JsonElement metadata = gson.toJsonTree(cellRaw.metadata);
        jsonObject.add("metadata", metadata);
      }
      if (cellRaw.level != null) {
        jsonObject.addProperty("level", cellRaw.level);
      }

      if (cellRaw.outputs != null) {
        final JsonElement outputs = gson.toJsonTree(cellRaw.outputs);
        jsonObject.add("outputs", outputs);
      }
      if (cellRaw.source != null) {
        final JsonElement source = gson.toJsonTree(cellRaw.source);
        jsonObject.add("source", source);
      }
      if (cellRaw.input != null) {
        final JsonElement input = gson.toJsonTree(cellRaw.input);
        jsonObject.add("input", input);
      }
      if (cellRaw.language != null) {
        jsonObject.addProperty("language", cellRaw.language);
      }
      if (cellRaw.prompt_number != null) {
        jsonObject.addProperty("prompt_number", cellRaw.prompt_number);
      }

      return jsonObject;
    }