Java Code Examples for com.dslplatform.json.NumberConverter#serialize()
The following examples show how to use
com.dslplatform.json.NumberConverter#serialize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetricRegistrySerializer.java From apm-agent-java with Apache License 2.0 | 6 votes |
static void serializeMetricSet(MetricSet metricSet, long epochMicros, StringBuilder replaceBuilder, JsonWriter jw) { jw.writeByte(JsonWriter.OBJECT_START); { DslJsonSerializer.writeFieldName("metricset", jw); jw.writeByte(JsonWriter.OBJECT_START); { DslJsonSerializer.writeFieldName("timestamp", jw); NumberConverter.serialize(epochMicros, jw); jw.writeByte(JsonWriter.COMMA); DslJsonSerializer.serializeLabels(metricSet.getLabels(), replaceBuilder, jw); DslJsonSerializer.writeFieldName("samples", jw); jw.writeByte(JsonWriter.OBJECT_START); boolean hasSamples = serializeGauges(metricSet.getGauges(), jw); hasSamples |= serializeTimers(metricSet.getTimers(), hasSamples, jw); serializeCounters(metricSet.getCounters(), hasSamples, jw); jw.writeByte(JsonWriter.OBJECT_END); } jw.writeByte(JsonWriter.OBJECT_END); } jw.writeByte(JsonWriter.OBJECT_END); }
Example 2
Source File: DslJsonSerializer.java From apm-agent-java with Apache License 2.0 | 6 votes |
private static void serializeScalarValue(StringBuilder replaceBuilder, JsonWriter jw, Object value, boolean extendedStringLimit, boolean supportsNonStringValues) { if (value instanceof String) { if (extendedStringLimit) { writeLongStringValue((String) value, replaceBuilder, jw); } else { writeStringValue((String) value, replaceBuilder, jw); } } else if (value instanceof Number) { if (supportsNonStringValues) { NumberConverter.serialize(((Number) value).doubleValue(), jw); } else { jw.writeNull(); } } else if (value instanceof Boolean) { if (supportsNonStringValues) { BoolConverter.serialize((Boolean) value, jw); } else { jw.writeNull(); } } else { // can't happen, as AbstractContext enforces the values to be either String, Number or boolean jw.writeString("invalid value"); } }
Example 3
Source File: DslJsonSerializer.java From apm-agent-java with Apache License 2.0 | 5 votes |
private void serializeResponse(final Response response) { if (response.hasContent()) { writeFieldName("response"); jw.writeByte(OBJECT_START); writeField("headers", response.getHeaders()); writeField("finished", response.isFinished()); writeField("headers_sent", response.isHeadersSent()); writeFieldName("status_code"); NumberConverter.serialize(response.getStatusCode(), jw); jw.writeByte(OBJECT_END); jw.writeByte(COMMA); } }
Example 4
Source File: MainActivity.java From dsl-json with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void serialize(JsonWriter writer, boolean minimal) { writer.writeAscii("{\"x\":"); NumberConverter.serialize(x, writer); writer.writeAscii(",\"s\":"); StringConverter.serialize(s, writer); writer.writeAscii("}"); }
Example 5
Source File: MainActivity.java From dsl-json with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void serialize(JsonWriter writer, boolean minimal) { writer.writeAscii("{\"x\":"); NumberConverter.serialize(x, writer); writer.writeAscii(",\"s\":"); StringConverter.serialize(s, writer); writer.writeAscii("}"); }
Example 6
Source File: World.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void serialize(JsonWriter writer, boolean minimal) { writer.writeAscii("{\"id\":"); NumberConverter.serialize(this.id, writer); writer.writeAscii(",\"randomNumber\":"); NumberConverter.serialize(this.randomNumber, writer); writer.writeByte(com.dslplatform.json.JsonWriter.OBJECT_END); }
Example 7
Source File: MetricRegistrySerializer.java From apm-agent-java with Apache License 2.0 | 4 votes |
private static void serializeCounter(String key, AtomicLong value, JsonWriter jw) { serializeValueStart(key, "", jw); NumberConverter.serialize(value.get(), jw); jw.writeByte(JsonWriter.OBJECT_END); value.set(0); }
Example 8
Source File: MetricRegistrySerializer.java From apm-agent-java with Apache License 2.0 | 4 votes |
private static void serializeValue(String key, String suffix, double value, JsonWriter jw) { serializeValueStart(key, suffix, jw); NumberConverter.serialize(value, jw); jw.writeByte(JsonWriter.OBJECT_END); }
Example 9
Source File: MetricRegistrySerializer.java From apm-agent-java with Apache License 2.0 | 4 votes |
private static void serializeValue(String key, String suffix, long value, JsonWriter jw) { serializeValueStart(key, suffix, jw); NumberConverter.serialize(value, jw); jw.writeByte(JsonWriter.OBJECT_END); }
Example 10
Source File: DslJsonSerializer.java From apm-agent-java with Apache License 2.0 | 4 votes |
private void writeField(final String fieldName, final long value) { writeFieldName(fieldName); NumberConverter.serialize(value, jw); jw.writeByte(COMMA); }
Example 11
Source File: DslJsonSerializer.java From apm-agent-java with Apache License 2.0 | 4 votes |
private void writeField(final String fieldName, final int value) { writeFieldName(fieldName); NumberConverter.serialize(value, jw); jw.writeByte(COMMA); }
Example 12
Source File: DslJsonSerializer.java From apm-agent-java with Apache License 2.0 | 4 votes |
private void writeLastField(final String fieldName, final int value) { writeFieldName(fieldName); NumberConverter.serialize(value, jw); }
Example 13
Source File: DslJsonSerializer.java From apm-agent-java with Apache License 2.0 | 4 votes |
private void writeField(final String fieldName, final double value) { writeFieldName(fieldName); NumberConverter.serialize(value, jw); jw.writeByte(COMMA); }
Example 14
Source File: DslJsonSerializer.java From apm-agent-java with Apache License 2.0 | 4 votes |
private void writeTimestamp(final long epochMicros) { writeFieldName("timestamp"); NumberConverter.serialize(epochMicros, jw); jw.writeByte(COMMA); }