weka.core.json
Class JSONInstances

java.lang.Object
  extended by weka.core.json.JSONInstances

public class JSONInstances
extends Object

Class for transforming Instances objects into JSON objects and vice versa. Missing values get stored as "?".

Version:
$Revision: 8034 $
Author:
FracPete (fracpete at waikato dot ac dot nz)
See Also:
MISSING_VALUE

Field Summary
static String ATTRIBUTES
          the attributes object.
static String CLASS
          the class attribute indicator.
static String DATA
          the data section.
static String DATEFORMAT
          the dateformat attribute.
static String HEADER
          the header section.
static String LABELS
          the labels attribute.
static String MISSING_VALUE
          the missing value indicator.
static String NAME
          the name attribute.
static String RELATION
          the relation name.
static String SPARSE
          the sparse attribute.
static String SPARSE_SEPARATOR
          the separator for index/value in case of sparse instances.
static String TYPE
          the type attribute.
static String VALUES
          the values attribute.
static String WEIGHT
          the weight attribute.
 
Constructor Summary
JSONInstances()
           
 
Method Summary
static void main(String[] args)
          For testing only.
static Instances toHeader(JSONNode json)
          Turns a JSON object, if possible, into an Instances object (only header).
static Instances toInstances(JSONNode json)
          Turns a JSON object, if possible, into an Instances object.
static JSONNode toJSON(Instances inst)
          Turns the Instances object into a JSON object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEADER

public static final String HEADER
the header section.

See Also:
Constant Field Values

DATA

public static final String DATA
the data section.

See Also:
Constant Field Values

RELATION

public static final String RELATION
the relation name.

See Also:
Constant Field Values

ATTRIBUTES

public static final String ATTRIBUTES
the attributes object.

See Also:
Constant Field Values

NAME

public static final String NAME
the name attribute.

See Also:
Constant Field Values

TYPE

public static final String TYPE
the type attribute.

See Also:
Constant Field Values

CLASS

public static final String CLASS
the class attribute indicator.

See Also:
Constant Field Values

LABELS

public static final String LABELS
the labels attribute.

See Also:
Constant Field Values

WEIGHT

public static final String WEIGHT
the weight attribute.

See Also:
Constant Field Values

DATEFORMAT

public static final String DATEFORMAT
the dateformat attribute.

See Also:
Constant Field Values

SPARSE

public static final String SPARSE
the sparse attribute.

See Also:
Constant Field Values

VALUES

public static final String VALUES
the values attribute.

See Also:
Constant Field Values

SPARSE_SEPARATOR

public static final String SPARSE_SEPARATOR
the separator for index/value in case of sparse instances.

See Also:
Constant Field Values

MISSING_VALUE

public static final String MISSING_VALUE
the missing value indicator.

See Also:
Constant Field Values
Constructor Detail

JSONInstances

public JSONInstances()
Method Detail

toInstances

public static Instances toInstances(JSONNode json)
Turns a JSON object, if possible, into an Instances object.

Parameters:
json - the JSON object to convert
Returns:
the generated Instances object, null if not possible

toHeader

public static Instances toHeader(JSONNode json)
Turns a JSON object, if possible, into an Instances object (only header).

Parameters:
json - the JSON object to convert
Returns:
the generated Instances header object, null if not possible

toJSON

public static JSONNode toJSON(Instances inst)
Turns the Instances object into a JSON object.

Parameters:
inst - the Instances to turn into a JSON object
Returns:
the JSON object

main

public static void main(String[] args)
                 throws Exception
For testing only.

Parameters:
args - expects a dataset as first parameter
Throws:
Exception - if something goes wrong


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.