Java Code Examples for org.json.JSONObject.valueToString()

The following are Jave code examples for showing how to use valueToString() of the org.json.JSONObject class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: spring-data-documentdb   File: DocumentDbConverterUnitTest.java   View Source Code Vote up 6 votes
@Test
public void testConvertFromDocumentToEntity() {
    final JSONObject json = new JSONObject();
    json.put(idPropertyName, id);
    json.put(firstNamePropertyName, firstName);
    json.put(lastNamePropertyName, lastName);
    json.put(hobbiesPropertyName, hobbies);
    json.put(shippingAddressesPropertyName, addresses);

    final Document document = new Document(JSONObject.valueToString(json));
    final Person person = dbConverter.convertFromDocument(document, Person.class);
    assertThat(person.getId()).isEqualTo(id);
    assertThat(person.getFirstName()).isEqualTo(firstName);
    assertThat(person.getLastName()).isEqualTo(lastName);
    assertThat(person.getHobbies().equals(hobbies));
    assertThat(person.getShippingAddresses().equals(addresses));
}