Exports this report into the standard JSON format which is consistent
across different language SDKs.

@return the encoded JSON string.
481727
public String exportToJson(boolean pretty) {
        Map<String, Object> result = new HashMap<String, Object>();
        Map<String, List<Map<String, Object>>> services = new HashMap<String, List<Map<String, Object>>>();

        for (EndpointHealth h : endpoints) {
            String type = serviceTypeFromEnum(h.type());
            if (!services.containsKey(type)) {
                services.put(type, new ArrayList<Map<String, Object>>());
            }
            List<Map<String, Object>> eps = services.get(type);
            eps.add(h.toMap());
        }

        result.put("version", version);
        result.put("services", services);
        result.put("sdk", sdk);
        result.put("id", id);

        try {
            if (pretty) {
                return DefaultObjectMapper.prettyWriter().writeValueAsString(result);
            } else {
                return DefaultObjectMapper.writeValueAsString(result);
            }
        } catch (JsonProcessingException e) {
            throw new IllegalStateException("Could not encode as JSON string.", e);
        }
    }
1167067
def export_as_json(self):
        
        result = {
            "subscription": self.subscription,
        }

        if self.name:
            result["name"] = self.name

        if self.ask is not None:
            result["ask"] = self.ask

        if self.approved:
            result["approved"] = self.approved

        if self.groups:
            result["groups"] = sorted(self.groups)

        return result
45685
public String toJSON()
	{
		StringBuffer sb = new StringBuffer();
		sb.append("{\n");
		
		// generate head
		sb.append("\t\"head\": {\n");
		if(!bindings.isEmpty()) {
			sb.append("\t\t\"vars\": [\n");
			QueryBinding top = bindings.get(0);
			boolean first = true;
			for(QueryArgument arg : top.getBoundArgs()) {
				if(arg.isVar()) {
					if(first) {
						first = false;
					}
					else {
						sb.append(",\n");
					}
					sb.append("\t\t\t\"");
					sb.append(arg.getValueAsString());
					sb.append("\"");
				}
			}
			sb.append("\n\t\t]\n");
		}
		sb.append("\t},\n");
		
		if(query.isAsk()) {
			if(ask) {
				sb.append("\t\"boolean\": true\n");
			}
			else {
				sb.append("\t\"boolean\": false\n");
			}
		}
		else {
			// otherwise generate results
			sb.append("\t\"results\": {\n");
			sb.append("\t\t\"bindings\": [\n");
			boolean firstBinding = true;
			for(QueryBinding binding : bindings) {
				if(firstBinding) {
					firstBinding = false;
				}
				else {
					sb.append(",\n");
				}
				sb.append("\t\t\t{\n");
				boolean firstVar = true;
				for(QueryArgument key : binding.getBoundArgs()) {
					if(key.isVar()) {
						if(firstVar) {
							firstVar = false;
						}
						else {
							sb.append(",\n");
						}
						sb.append("\t\t\t\t\"");
						sb.append(key.getValueAsString());
						sb.append("\": {\n");
						QueryArgument value = binding.get(key);
						switch(value.getType()) {
						case URI:
							sb.append("\t\t\t\t\t\"type\": \"uri\",\n");
							sb.append("\t\t\t\t\t\"value\": \"");
							sb.append(value.getValueAsIRI().toString().replaceAll("\"", "\\\\\""));
							sb.append("\"\n");
							break;
						case LITERAL:
							sb.append("\t\t\t\t\t\"type\": \"literal\",\n");
							sb.append("\t\t\t\t\t\"value\": \"");
							sb.append(value.getValueAsLiteral().getLiteral().replaceAll("\"", "\\\\\""));
							sb.append("\"\n");
							break;
						case BNODE:
							sb.append("\t\t\t\t\t\"type\": \"bnode\",\n");
							sb.append("\t\t\t\t\t\"value\": \"");
							sb.append(value.getValueAsBNode().getID().toString().replaceAll("\"", "\\\\\""));
							sb.append("\"\n");
							break;
						default:
						}
						sb.append("\t\t\t\t}");
					}
				}
				sb.append("\n\t\t\t}");
			}
			sb.append("\n\t\t]\n\t}\n");
		}
		sb.append("}\n");
		
		return sb.toString();
	}
146791
public String toJSONString() {
    return JSON.toJSONString(this, ObjectValueFilter.instance,
          SerializerFeature.WriteClassName,
          SerializerFeature.DisableCircularReferenceDetect);
  }
913813
@VisibleForTesting
  byte[] getStorageJSON() {
    // TODO - precalculate size
    final ByteArrayOutputStream output = new ByteArrayOutputStream();
    try {
      final JsonGenerator json = JSON.getFactory().createGenerator(output); 
      json.writeStartObject();
      if (tsuid != null && !tsuid.isEmpty()) {
        json.writeStringField("tsuid", tsuid);  
      }
      json.writeNumberField("startTime", start_time);
      json.writeNumberField("endTime", end_time);
      json.writeStringField("description", description);
      json.writeStringField("notes", notes);
      if (custom == null) {
        json.writeNullField("custom");
      } else {
        final TreeMap<String, String> sorted_custom = 
            new TreeMap<String, String>(custom);
        json.writeObjectField("custom", sorted_custom);
      }
      
      json.writeEndObject(); 
      json.close();
      return output.toByteArray();
    } catch (IOException e) {
      throw new RuntimeException("Unable to serialize Annotation", e);
    }
  }
903000
public String toJsonString() {
    	JSONArray jsonArray = new JSONArray();        
        for (Collection<LineSeriesItem<I, V>> col : data) {
        	JSONArray serie = new JSONArray();
        	for (LineSeriesItem<I, V> lineSeriesItem : col) {
                JSONArray itemArray = new JSONArray();
                itemArray.put(lineSeriesItem.getIndex());
                itemArray.put(lineSeriesItem.getValue());
                serie.put(itemArray);
			}
        	jsonArray.put(serie);
        	
        }
        return jsonArray.toString();
	}
1321619
public String toJsonString() {
        JSONArray outerArray = new JSONArray();
        JSONArray jsonArray = new JSONArray();
        for (BubbleItem item : data) {
            JSONArray itemArray = new JSONArray();
            itemArray.put(item.getX());
            itemArray.put(item.getY());
            itemArray.put(item.getRadius());
            itemArray.put(item.getLabel());
            jsonArray.put(itemArray);
        }
        outerArray.put(jsonArray);
        return outerArray.toString();
    }
1359971
public final String toJson() {
    Gson gson = new GsonBuilder()
      .registerTypeAdapter(BoundingBox.class, new BoundingBoxTypeAdapter())
      .create();
    return gson.toJson(this, BoundingBox.class);
  }
596400
public String toStrippedJsonString() {
        try {
            final Map<String, Object> json = new LinkedHashMap<>();
            json.put("alert", this.message.getAlert());
            json.put("priority", this.message.getPriority().toString());
            if (this.getMessage().getBadge()>0) {
                json.put("badge", Integer.toString(this.getMessage().getBadge()));
            }
            json.put("criteria", this.criteria);
            json.put("config", this.config);
            return OBJECT_MAPPER.writeValueAsString(json);
        } catch (JsonProcessingException e) {
            return "[\"invalid json\"]";
        } catch (IOException e) {
            return "[\"invalid json\"]";
        }
    }
1033219
public JSONObject toJSON() {
        JSONObject ret = super.toJSON();
        if (arguments != null && arguments.size() > 0) {
            ret.put("arguments", arguments);
        }
        ret.put("operation", operation);
        return ret;
    }
694544
public String toJsonString() {
    	JSONArray jsonArray = new JSONArray();        
        for (LabeledItem<T> labeledItem : data) {
            JSONArray itemArray = new JSONArray();
            itemArray.put(labeledItem.getLabel());
            itemArray.put(labeledItem.getValue());
            jsonArray.put(itemArray);
        }
        JSONArray outerArray = new JSONArray();
        outerArray.put(jsonArray);
        return outerArray.toString();
    }
986853
public String toJSON() {

        StringBuffer result = new StringBuffer();
        result.append("{\n");
        for (Entry<String, List<String>> simpleEntry : m_simpleAttributes.entrySet()) {
            result.append("\"").append(simpleEntry.getKey()).append("\"").append(": [\n");
            boolean firstValue = true;
            for (String value : simpleEntry.getValue()) {
                if (firstValue) {
                    firstValue = false;
                } else {
                    result.append(",\n");
                }
                result.append("\"").append(value).append("\"");
            }
            result.append("],\n");
        }
        for (Entry<String, List<CmsEntity>> entityEntry : m_entityAttributes.entrySet()) {
            result.append("\"").append(entityEntry.getKey()).append("\"").append(": [\n");
            boolean firstValue = true;
            for (CmsEntity value : entityEntry.getValue()) {
                if (firstValue) {
                    firstValue = false;
                } else {
                    result.append(",\n");
                }
                result.append(value.toJSON());
            }
            result.append("],\n");
        }
        result.append("\"id\": \"").append(m_id).append("\"");
        result.append("}");
        return result.toString();
    }
456150
public JsonNode toJson() {
		ObjectNode node = new ObjectMapper().createObjectNode();
		node.put("code", code);
		if (format != null) {
			node.put("format", format);
		}
		return node;
	}
998651
public String getJSONMessages() {
		StringBuilder builder = new StringBuilder();
		builder.append("{");
		
		boolean first = true;
		Enumeration<String> keys = this.bundle.getKeys();
		while (keys.hasMoreElements()) {
			if (!first)
				builder.append(",");
			else
				first = false;
			String key = keys.nextElement();
			String value = this.getMessage(key);
			String escaped = value.replaceAll("\\'", "\\\\'");
			builder.append("'").append(key).append("':'").append(escaped).append("'");
		}
		
		builder.append("}");
		return builder.toString();
	}
454973
public JSONObject toJson() {
        JSONObject ret = new JSONObject();
        ret.put("url",url);
        if (user != null) {
            ret.put("user",user);
            ret.put("password",password);
        }
        return ret;
    }
570669
def to_JSON(self):
        
        return json.dumps({'id': self.id,
                           'external_id': self.external_id,
                           'name': self.name,
                           'created_at': timeformatutils.to_ISO8601(self.created_at),
                           'updated_at': timeformatutils.to_ISO8601(self.updated_at),
                           'lat': self.lat,
                           'lon': self.lon,
                           'alt': self.alt if self.alt is not None else 'None',
                           'rank': self.rank})
968538
public JSONObject toJson() throws JSONException {

        JSONObject result = new JSONObject();
        if (m_detailId != null) {
            result.put(JSON_DETAIL, "" + m_detailId);
        }
        if (m_siteRoot != null) {
            result.put(JSON_SITEROOT, m_siteRoot);
        }
        if (m_structureId != null) {
            result.put(JSON_STRUCTUREID, "" + m_structureId);
        }
        if (m_projectId != null) {
            result.put(JSON_PROJECT, "" + m_projectId);
        }
        if (m_type != null) {
            result.put(JSON_TYPE, "" + m_type.getJsonId());
        }
        return result;
    }