Postgresql, commas in string_agg function Need

FIELD like this, with ' and without , at the end of whole field.

{name:'color',value:'red'},{name:'width',value:'300 ml'}


Tried

string_agg(distinct '{name:\'' || param_name || '\',value:\'' || value || '\'},','') as "FIELD"


but error behind 2nd \

SQL Error [42601]: ERROR: syntax error at or near "\"


With , at the end of whole field, I don't know how to do that.

Thanks.
If you want to generate JSON, it is easier to use JSON functions for that, e.g.:

string_agg(distinct jsonb_build_object('name', param_name, 'value', value)::text, ',')


Or create a proper JSON array of the result:

jsonb_agg(distinct jsonb_build_object('name', param_name, 'value', value))


Online example: https://rextester.com/EPOX97933