Java Code Examples for org.boon.json.JsonFactory#toJson()
The following examples show how to use
org.boon.json.JsonFactory#toJson() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CBArray.java From jdbc-cb with Apache License 2.0 | 5 votes |
CBArray(List arrayList) { if (arrayList == null ) { array=null; jsonArray=null; } else { array = arrayList.toArray(); jsonArray = JsonFactory.toJson(array); } }
Example 2
Source File: SqlJsonImplementation.java From jdbc-cb with Apache License 2.0 | 5 votes |
private synchronized void toJson() { if (sqlJson == null ) { sqlJson = JsonFactory.toJson(jsonObject); } }
Example 3
Source File: CBArray.java From jdbc-cb with Apache License 2.0 | 4 votes |
CBArray(String typeName, Object[] array) { this.array = array; baseType = typeName; jsonArray = JsonFactory.toJson(array); }
Example 4
Source File: Credentials.java From jdbc-cb with Apache License 2.0 | 4 votes |
public String toString() { return JsonFactory.toJson(credentials); }
Example 5
Source File: ProtocolImpl.java From jdbc-cb with Apache License 2.0 | 4 votes |
public CouchResponse doQuery(String query, Map queryParameters) throws SQLException { Instance endPoint = getNextEndpoint(); // keep trying endpoints while(true) { try { String url = endPoint.getEndpointURL(ssl); logger.trace("Using endpoint {}", url); HttpPost httpPost = new HttpPost(url); httpPost.setHeader("Accept", "application/json"); logger.trace("do query {}", httpPost.toString()); addOptions(queryParameters); String jsonParameters = JsonFactory.toJson(queryParameters); StringEntity entity = new StringEntity(jsonParameters, ContentType.APPLICATION_JSON); httpPost.setEntity(entity); CloseableHttpResponse response = httpClient.execute(httpPost); return handleResponse(query, response); } catch (ConnectTimeoutException cte) { logger.trace(cte.getLocalizedMessage()); // this one failed, lets move on invalidateEndpoint(endPoint); // get the next one endPoint = getNextEndpoint(); if (endPoint == null) { throw new SQLException("All endpoints have failed, giving up"); } } catch (Exception ex) { logger.error("Error executing query [{}] {}", query, ex.getMessage()); throw new SQLException("Error executing update", ex); } } }
Example 6
Source File: Bug312.java From boon with Apache License 2.0 | 4 votes |
@Test public void test() { MyClass myClass = new MyClass(); final String json = JsonFactory.toJson(myClass); final MyClass myClass1 = JsonFactory.fromJson(json, MyClass.class); assertEquals("foo", myClass1.string); assertEquals(1, myClass1.integer); assertNull(myClass1.map); }
Example 7
Source File: Bug312.java From boon with Apache License 2.0 | 4 votes |
@Test public void testWithMap() { MyClass myClass = new MyClass(); myClass.map = new HashMap<>(); myClass.map.put("foo", "bar"); final String json = JsonFactory.toJson(myClass); final MyClass myClass1 = JsonFactory.fromJson(json, MyClass.class); assertEquals("foo", myClass1.string); assertEquals(1, myClass1.integer); assertEquals("bar", myClass1.map.get("foo")); }
Example 8
Source File: BugReport165AndIssue169.java From boon with Apache License 2.0 | 4 votes |
@Test public void test4() { Sample sample1 = new Sample(); String json = JsonFactory.toJson(sample1); puts(json); puts (sample1); ok = json.contains("\"effectiveDate\"") || die(); Sample sample2 = JsonFactory.fromJson(json, Sample.class); puts ("sample2", sample2); puts ("sample2", JsonFactory.toJson(sample2)); ok = sample1.equals(sample2); }
Example 9
Source File: Bug311.java From boon with Apache License 2.0 | 3 votes |
@Test public void test () { final String json = JsonFactory.toJson(new SimpleObject()); final SimpleObject simpleObject = JsonFactory.fromJson(json, SimpleObject.class); assertEquals(Float.NEGATIVE_INFINITY, simpleObject.f1, 0.1); assertEquals(Float.NaN, simpleObject.f2, 0.1); }
Example 10
Source File: Boon.java From boon with Apache License 2.0 | 2 votes |
/** * Helper method to quickly convert a Java object into JSON. * Facade into the JSON system. * * @param value Java object * @return JSON-ified Java object */ public static String toJson(Object value) { return JsonFactory.toJson(value); }