Example usage for com.badlogic.gdx.utils JsonValue asDouble

List of usage examples for com.badlogic.gdx.utils JsonValue asDouble

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils JsonValue asDouble.

Prototype

public double asDouble() 

Source Link

Document

Returns this value as a double.

Usage

From source file:br.com.questingsoftware.libgdx.g3db.G3DBConverter.java

License:Apache License

private void writeObject(JsonValue root, UBJsonWriter writer) throws IOException {
    if (root.type() == ValueType.array) {
        if (root.name() != null) {
            writer.array(root.name());// w w w.j a v  a 2s. c om
        } else {
            writer.array();
        }
    } else {
        if (root.name() != null) {
            writer.object(root.name());
        } else {
            writer.object();
        }
    }

    JsonValue child = root.child();
    while (child != null) {
        switch (child.type()) {
        case booleanValue:
            if (child.name() != null) {
                writer.set(child.name(), child.asBoolean());
            } else {
                writer.value(child.asBoolean());
            }
            break;

        case doubleValue:
            if (child.name() != null) {
                writer.set(child.name(), child.asDouble());
            } else {
                writer.value(child.asDouble());
            }
            break;

        case longValue:
            if (child.name() != null) {
                writer.set(child.name(), child.asLong());
            } else {
                writer.value(child.asLong());
            }
            break;

        case stringValue:
            if (child.name() != null) {
                writer.set(child.name(), child.asString());
            } else {
                writer.value(child.asString());
            }
            break;

        case nullValue:
            if (child.name() != null) {
                writer.set(child.name());
            }
            break;

        case array:
        case object:
            writeObject(child, writer);
            break;
        }

        child = child.next();
    }

    writer.pop();
}