Example #1
0
void
parcJSONValue_Display(const PARCJSONValue *value, int indentation)
{
    parcDisplayIndented_PrintLine(indentation, "PARCJSONValue@%p {", value);
    if (value != NULL) {
        parcDisplayIndented_PrintLine(indentation + 1, ".type=%d", value->type);

        switch (value->type) {
            case PARCJSONValueType_Boolean:
                _displayBoolean(value, indentation + 1);
                break;
            case PARCJSONValueType_String:
                parcBuffer_Display(value->value.string, indentation + 1);
                break;
            case PARCJSONValueType_Number:
                _displayNumber(value, indentation + 1);
                break;
            case PARCJSONValueType_Array:
                parcJSONArray_Display(value->value.array, indentation + 1);
                break;
            case PARCJSONValueType_JSON:
                parcJSON_Display(value->value.object, indentation + 1);
                break;
            case PARCJSONValueType_Null:
                parcDisplayIndented_PrintLine(indentation + 1, ".value=null");
                break;
            default:
                trapIllegalValue(value->type, "Unknown PARCJSONValue type %d", value->type);
        }
    }
    parcDisplayIndented_PrintLine(indentation, "}");
}
Example #2
0
LONGBOW_TEST_CASE(parc_JSONArray, parcJSONArray_Display)
{
    PARCJSONArray *array = parcJSONArray_Create();
    PARCJSONValue *expected = parcJSONValue_CreateFromInteger(10);
    parcJSONArray_AddValue(array, expected);
    parcJSONValue_Release(&expected);

    parcJSONArray_Display(array, 0);

    parcJSONArray_Release(&array);
}