MinXSON Tutorial

Work in Progress

In this section we show how to read in a MinXSON expression, generating a MinXML object. We will use the class com.steelypip.powerups.minxson.MinXSONParser to read from a java.io.Reader source.

As input we'll use the following MinXSON file, data.minxson. As you can see, we have got a mixture of elements,

    [ "steve", "liam", "ingram", "craig", "stephen" ],
    <data time-recorded="12:14">

To parse this, we simply use the constructor of MinXSONParser to create a parser, which will read from the data.minxson file once it has been changed into a Reader via java.io.FileReader.

import com.steelypip.powerups.minxson.MinXSONParser;
import java.io.FileReader;
import java.io.OutputStreamWriter;
MinXML minxml = new MinXSONParser( new FileReader( "data.minxson" ) ).read();
minxml.prettyPrint( new OutputStreamWriter( System.out ) );

This generates the following MinXML output:

        <constant type="string" value="steve"/>
        <constant type="string" value="liam"/>
        <constant type="string" value="ingram"/>
        <constant type="string" value="craig"/>
        <constant type="string" value="stephen"/>
    <data time-recorded="12:14">
        <constant type="float" value="0.1"/>
        <id name="i"/>
        <constant type="float" value="0.3"/>
        <constant type="integer" value="-3"/>
        <constant type="integer" value="4"/>