[JAVA-9056] Upgrade JSON-java lib version

This commit is contained in:
Haroon Khan 2022-01-01 19:11:19 +00:00
parent e10f813a93
commit 94c6cb3872
3 changed files with 7 additions and 4 deletions

View File

@ -13,4 +13,4 @@ This module contains articles about JSON.
- [Iterating Over an Instance of org.json.JSONObject](https://www.baeldung.com/jsonobject-iteration)
- [Escape JSON String in Java](https://www.baeldung.com/java-json-escaping)
- [Reducing JSON Data Size](https://www.baeldung.com/json-reduce-data-size)
- More Articles: [[next -->]](/json-2)
- More Articles: [[next -->]](../json-2)

View File

@ -69,7 +69,7 @@
<everit.json.schema.version>1.4.1</everit.json.schema.version>
<jsonb-api.version>1.0</jsonb-api.version>
<yasson.version>1.0.1</yasson.version>
<json.version>20171018</json.version>
<json.version>20211205</json.version>
<gson.version>2.8.5</gson.version>
<javax.version>1.1.2</javax.version>
</properties>

View File

@ -1,5 +1,6 @@
package com.baeldung.jsonjava;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import org.json.Cookie;
@ -14,7 +15,7 @@ public class CookieIntegrationTest {
assertEquals("{\"path\":\"/\",\"expires\":\"Thu, 18 Dec 2013 12:00:00 UTC\",\"name\":\"username\",\"value\":\"John Doe\"}", cookieJO.toString());
}
@Test
public void givenJSONObject_thenConvertToCookieString() {
JSONObject cookieJO = new JSONObject();
@ -22,8 +23,10 @@ public class CookieIntegrationTest {
cookieJO.put("value", "John Doe");
cookieJO.put("expires", "Thu, 18 Dec 2013 12:00:00 UTC");
cookieJO.put("path", "/");
String cookie = Cookie.toString(cookieJO);
assertEquals("username=John Doe;expires=Thu, 18 Dec 2013 12:00:00 UTC;path=/", cookie.toString());
assertThat(cookie.split(";"))
.containsExactlyInAnyOrder("username=John Doe", "path=/", "expires=Thu, 18 Dec 2013 12:00:00 UTC");
}
}