Package org.codehaus.jettison.json

Examples of org.codehaus.jettison.json.JSONTokener


        if (charset == null) {
            charset = "UTF-8";
        }
        try {
            String doc = readAll(is, charset);
            return createXMLStreamReader(new JSONTokener(doc));
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here


   
    public abstract XMLStreamReader createXMLStreamReader(JSONTokener tokener) throws XMLStreamException;

    public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException {
        try {
            return createXMLStreamReader(new JSONTokener(readAll(reader)));
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }
View Full Code Here

                        jmConfig = new Configuration();
                    } else {
                        jmConfig = new Configuration(config.getXml2JsonNs());
                    }
                    return new MappedXMLStreamReader(
                            new JSONObject(new JSONTokener(ReaderWriter.readFromAsString(nonEmptyReader))),
                            new MappedNamespaceConvention(jmConfig));
                } catch (Exception ex) {
                    throw new XMLStreamException(ex);
                }
            case BADGERFISH:
                try {
                    return new BadgerFishXMLStreamReader(new JSONObject(new JSONTokener(ReaderWriter.readFromAsString(nonEmptyReader))));
                } catch (Exception ex) {
                    throw new XMLStreamException(ex);
                }
        }
        // This should not occur
View Full Code Here

                        jmConfig = new Configuration();
                    } else {
                        jmConfig = new Configuration(config.getXml2JsonNs());
                    }
                    return new MappedXMLStreamReader(
                            new JSONObject(new JSONTokener(readFromAsString(reader))),
                            new MappedNamespaceConvention(jmConfig));
                } catch (Exception ex) {
                    Logger.getLogger(JSONUnmarshaller.class.getName()).log(Level.SEVERE, null, ex);
                }
                break;
            case BADGERFISH:
                try {
                    return new BadgerFishXMLStreamReader(new JSONObject(new JSONTokener(readFromAsString(reader))));
                } catch (Exception ex) {
                    Logger.getLogger(JSONUnmarshaller.class.getName()).log(Level.SEVERE, null, ex);
                }
                break;
        }
View Full Code Here

                ClientResponse response = this.doGraphPost(testGraph, "edges", "_outV=" + encode(vertexIdOut) + "&_inV=" + encode(vertexIdIn) + "&_label=uriPost" + complexKeyValueUri);
                assertPostedEdge(vertexIdIn, vertexIdOut, response, false);
   
                // post as JSON
                String complexKeyValueJson = "{\"propertya\":123,\"propertyb\":321.5,\"propertyc\":[\"x\",\"y\",\"z\"],\"propertyd\":{\"x\":\"xyz\"}}";
                JSONTokener tokener = new JSONTokener(complexKeyValueJson);
                JSONObject complexJsonObject = new JSONObject(tokener);
   
                Map<String, Object> jsonEdgeData = new HashMap<String, Object>();
                jsonEdgeData.put(Tokens._OUT_V, vertexIdOut);
                jsonEdgeData.put(Tokens._IN_V, vertexIdIn);
View Full Code Here

                ClientResponse response = this.doGraphPut(testGraph, "edges/" + encode(firstEdgeId), complexKeyValueUri);
                assertPuttedEdge(firstEdgeId, response, false);

                // put as JSON
                String complexKeyValueJson = "{\"propertya\":123,\"propertyb\":321.5,\"propertyc\":[\"x\",\"y\",\"z\"],\"propertyd\":{\"x\":\"xyz\"}}";
                JSONTokener tokener = new JSONTokener(complexKeyValueJson);
                JSONObject complexJsonObject = new JSONObject(tokener);
                Map<String, Object> jsonEdgeData = new HashMap<String, Object>();
                jsonEdgeData.put("complex", complexJsonObject);

                JSONObject jsonEdgeToPost = new JSONObject(jsonEdgeData);
View Full Code Here

        Assert.assertEquals(new Long(0), RequestObjectHelper.getStartOffset(null));
    }

    private JSONObject buildJSONObjectFromString(String json) {
        try {
            JSONTokener tokener = new JSONTokener(json);
            return new JSONObject(tokener);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

    @Test
    public void evaluateGetOnGraphWithBindings() throws Exception {
        String json = "{\"params\":{\"x\":1, \"y\":2, \"z\":\"test\", \"list\":[3,2,1,0], \"map\":{\"mapx\":[300,200,100]}}}";
        RexsterResourceContext rexsterResourceContext = new RexsterResourceContext(null, uriInfo,
                httpServletRequest, new JSONObject(new JSONTokener(json)), null, extensionMethodNoApi, null, new MetricRegistry());

        ExtensionResponse extensionResponse = this.gremlinExtension.evaluateGetOnGraph(
                rexsterResourceContext, graph, "[x+y, z, list.size, map.mapx.size]");
        JSONObject jsonResponse = assertResponseAndGetEntity(extensionResponse,
                Response.Status.OK.getStatusCode());
View Full Code Here

     */
    public JSONObject jsonFromElement(final Element element) throws JSONException {
        final ObjectNode objectNode = this.objectNodeFromElement(element);

        try {
            return new JSONObject(new JSONTokener(mapper.writeValueAsString(objectNode)));
        } catch (IOException ioe) {
            // repackage this as a JSONException...seems sensible as the caller will only know about
            // the jettison object not being created
            throw new JSONException(ioe);
        }
View Full Code Here

         do
         {
            wasRead = bufferedReader.read(buffer, 0, 100);
            if (wasRead > 0) buf.append(buffer, 0, wasRead);
         } while (wasRead > -1);
         badger = new MappedXMLStreamReader(new JSONObject(new JSONTokener(buf.toString())), convention);
      }
      catch (Exception e)
      {
         throw new JAXBException(e);
      }
View Full Code Here

TOP

Related Classes of org.codehaus.jettison.json.JSONTokener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.