public static void appendAsJsonString(final StringBuilder sb, final PrimitiveValue value, final Encoding encoding)
    {
        switch (encoding.primitiveType())
        {
            case CHAR:
                sb.append('\'').append((char)value.longValue()).append('\'');
                break;

            case INT8:
            case UINT8:
            case INT16:
            case UINT16:
            case INT32:
            case UINT32:
            case INT64:
            case UINT64:
                sb.append(value.longValue());
                break;

            case FLOAT:
            {
                final float floatValue = (float)value.doubleValue();
                if (Float.isNaN(floatValue))
                {
                    sb.append("0/0");
                }
                else if (floatValue == Float.POSITIVE_INFINITY)
                {
                    sb.append("1/0");
                }
                else if (floatValue == Float.NEGATIVE_INFINITY)
                {
                    sb.append("-1/0");
                }
                else
                {
                    sb.append(value);
                }
                break;
            }

            case DOUBLE:
            {
                final double doubleValue = value.doubleValue();
                if (Double.isNaN(doubleValue))
                {
                    sb.append("0/0");
                }
                else if (doubleValue == Double.POSITIVE_INFINITY)
                {
                    sb.append("1/0");
                }
                else if (doubleValue == Double.NEGATIVE_INFINITY)
                {
                    sb.append("-1/0");
                }
                else
                {
                    sb.append(doubleValue);
                }
                break;
            }
        }
    }
Append a value as a Json String to a {@link StringBuilder}.

@param sb       to append the value to.
@param value    to append.
@param encoding representing the encoded value.
sbe-tool/src/main/java/uk/co/real_logic/sbe/otf/Types.java