package com.hubspot.jinjava.lib.filter;

import java.util.Objects;

import org.apache.commons.lang3.StringEscapeUtils;

import com.hubspot.jinjava.doc.annotations.JinjavaDoc;
import com.hubspot.jinjava.doc.annotations.JinjavaParam;
import com.hubspot.jinjava.doc.annotations.JinjavaSnippet;
import com.hubspot.jinjava.interpret.JinjavaInterpreter;

@JinjavaDoc(
    value = "Uses StringEscapeUtils.escapeJson() to escape strings so that they can be used in JSON values",
    params = {
        @JinjavaParam(value = "s", desc = "String to escape")
    },
    snippets = {
        @JinjavaSnippet(
            code = "{{String that contains JavaScript|escapejson}}"
        )
    })

public class EscapeJsonFilter implements Filter {

  @Override
  public String getName() {
    return "escapejson";
  }

  @Override
  public Object filter(Object var, JinjavaInterpreter interpreter, String... args) {
    return StringEscapeUtils.escapeJson(Objects.toString(var));
  }
}

@@ -372,53 +372,15 @@
  = %22
-Uses StringEscapeUtils.escapeJson() to escape
+Escapes
  str
@@ -409,18 +409,18 @@
 be used 
-in
+as
  JSON va

update doc string