Package argo.staj

Examples of argo.staj.StajParser


     * @param jsonListener the JsonListener to notify of parsing events
     * @throws IOException            bubbled up from exceptions thrown reading from {@code in}
     * @throws InvalidSyntaxException thrown to indicate the characters read from {@code in} did not constitute valid JSON.
     */
    public void parse(final String json, final JsonListener jsonListener) throws IOException, InvalidSyntaxException {
        parse(jsonListener, new StajParser(new StringReader(json)));
    }
View Full Code Here


     * @param jsonListener the JsonListener to notify of parsing events
     * @throws IOException            bubbled up from exceptions thrown reading from {@code in}
     * @throws InvalidSyntaxException thrown to indicate the characters read from {@code in} did not constitute valid JSON.
     */
    public void parse(final Reader in, final JsonListener jsonListener) throws IOException, InvalidSyntaxException {
        parse(jsonListener, new StajParser(in));
    }
View Full Code Here

    @Test
    public void parsesUsingStaj() throws Exception {
        final FileReader jsonReader = new FileReader(new File(this.getClass().getResource("SimpleExample.json").getFile()));
        Set<String> fieldNames = new HashSet<String>();
        final StajParser stajParser = new StajParser(jsonReader);
        while (stajParser.hasNext()) {
            JsonStreamElement next = stajParser.next();
            if (next.jsonStreamElementType() == JsonStreamElementType.START_FIELD) {
                fieldNames.add(next.text());
            }
        }
        assertThat(fieldNames, equalTo((Set<String>) new HashSet<String>(Arrays.asList("name", "sales", "totalRoyalties", "singles"))));
View Full Code Here

    }

    @Test
    public void testArgoStaj() throws Exception {
        for (final Reader reader : jsonReaders) {
            final StajParser stajParser = new StajParser(reader);
            while (stajParser.hasNext()) {
                stajParser.next();
            }
        }
    }
View Full Code Here

TOP

Related Classes of argo.staj.StajParser

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.