Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ int sendAt = header.getSendAt();
String headers = header.jsonString();
```

If you need the unescaped JSON string.
```java
String rawJson = header.rawJsonString();
```

## Running Tests

```
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/sendgrid/smtpapi/SMTPAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,8 @@ private String escapeUnicode(String input) {
public String jsonString() {
return escapeUnicode(this.header.toString());
}

public String rawJsonString() {
return this.header.toString();
}
}
8 changes: 8 additions & 0 deletions src/test/java/com/sendgrid/smtpapi/SMTPAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ public class SMTPAPITest {
Assert.assertEquals(expected, test.jsonString());
}

@Test public void testRawJsonString() {
test.addCategory("カテゴリUñicode");
test.addCategory("カテゴリ2Unicode");
test.addCategory("鼖");
String expected = "{\"category\":[\"カテゴリUñicode\",\"カテゴリ2Unicode\",\"鼖\"]}";
Assert.assertEquals(expected, test.rawJsonString());
}

@Test public void testAddCategories() throws JSONException {
String[] expected = new String[]{"test", "test2"};
test.addCategories(expected);
Expand Down