Skip to content

Stringification

These pipes are used to stringify the given values.

Plain stringification

This value returns a string of the given value.

1
2
3
4
5
6
7
8
const value = {
    prop1: "my prop value",
    prop2: "my another prop value"
};

const pipe = getValuePipe('stringify');

console.log(pipe(value))

Output

'{"prop1":"my prop value","prop2":"my another prop value"}'
const fieldSchema: SchemaInput = {
    fields: {
        prop1: {
            type: 'constant-value',
            config: {
                value: 'my prop value'
            }
        },
        prop2: {
            type: 'constant-value',
            config: {
                value: 'my another prop value'
            }
        }
    }
}

const generator = getValueGenerator('object-from-schema', {
    schema: fieldSchema,
    pipes: [
        'stringify'
    ]
});

console.log(generator.generate())

Output

'{"prop1":"my prop value","prop2":"my another prop value"}'

Tip

This example uses Object Generator. You may want to check it out 😉