Remove quotes from a json string with replace typescript

Asked

Viewed 301 times

0

I need to remove the quotes from a string I receive in json, for this I am creating a pipe, but I am not able to remove double quotes.

I tried something like:

@Pipe({
  name: 'prettyprint'
})
export class PrettyPrintPipe implements PipeTransform {
  transform(val) {
    return JSON.stringify(val, null, 2)
      .replace("\"", "")
      .replace("{", "")
      .replace("}", "");
  }
}

Também tentei:
 .replace(`""`, "")

But without success, the quotes don’t come out.

Any idea?

  • Have you tried using REGEX to "delete" the quotes? <https://www.w3schools.com/jsref/jsref_obj_regexp.asp>

  • tries the famous Symbol('"');

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.