/** Finds the child with the specified name and returns it as a string. * @throws IllegalArgumentException if the child was not found. */ public String getString (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asString(); }
/** Finds the child with the specified name and returns it as a string. * @throws IllegalArgumentException if the child was not found. */ public String getString (String name) { JsonValue child = get(name); if (child == null) throw new IllegalArgumentException("Named value not found: " + name); return child.asString(); }
/** Finds the child with the specified index and returns it as a string. * @throws IllegalArgumentException if the child was not found. */ public String getString (int index) { JsonValue child = get(index); if (child == null) throw new IllegalArgumentException("Indexed value not found: " + name); return child.asString(); }
/** Finds the child with the specified index and returns it as a string. * @throws IllegalArgumentException if the child was not found. */ public String getString (int index) { JsonValue child = get(index); if (child == null) throw new IllegalArgumentException("Indexed value not found: " + name); return child.asString(); }
/** Finds the child with the specified name and returns it as a string. Returns defaultValue if not found. * @param defaultValue May be null. */ public String getString (String name, String defaultValue) { JsonValue child = get(name); return (child == null || !child.isValue() || child.isNull()) ? defaultValue : child.asString(); }
/** Finds the child with the specified name and returns it as a string. Returns defaultValue if not found. * @param defaultValue May be null. */ public String getString (String name, String defaultValue) { JsonValue child = get(name); return (child == null || !child.isValue() || child.isNull()) ? defaultValue : child.asString(); }
public String toJson (OutputType outputType) { if (isValue()) return asString(); StringBuilder buffer = new StringBuilder(512); json(this, buffer, outputType); return buffer.toString(); }
public String toJson (OutputType outputType) { if (isValue()) return asString(); StringBuilder buffer = new StringBuilder(512); json(this, buffer, outputType); return buffer.toString(); }
public <T> T readValue (Class<T> type, Class elementType, JsonValue jsonData) { // If the JSON is a string but the type is not, look up the actual value by name. if (jsonData.isString() && !ClassReflection.isAssignableFrom(CharSequence.class, type)) return get(jsonData.asString(), type); return super.readValue(type, elementType, jsonData); }
public <T> T readValue (Class<T> type, Class elementType, JsonValue jsonData) { // If the JSON is a string but the type is not, look up the actual value by name. if (jsonData.isString() && !ClassReflection.isAssignableFrom(CharSequence.class, type)) return get(jsonData.asString(), type); return super.readValue(type, elementType, jsonData); }
writer.append(outputType.quoteValue(object.asString())); } else if (object.isDouble()) { double doubleValue = object.asDouble();
private VertexAttribute[] parseAttributes (JsonValue attributes) { Array<VertexAttribute> vertexAttributes = new Array<VertexAttribute>(); int unit = 0; int blendWeightCount = 0; for (JsonValue value = attributes.child; value != null; value = value.next) { String attribute = value.asString(); String attr = (String)attribute; if (attr.equals("POSITION")) { vertexAttributes.add(VertexAttribute.Position()); } else if (attr.equals("NORMAL")) { vertexAttributes.add(VertexAttribute.Normal()); } else if (attr.equals("COLOR")) { vertexAttributes.add(VertexAttribute.ColorUnpacked()); } else if (attr.equals("COLORPACKED")) { vertexAttributes.add(VertexAttribute.ColorPacked()); } else if (attr.equals("TANGENT")) { vertexAttributes.add(VertexAttribute.Tangent()); } else if (attr.equals("BINORMAL")) { vertexAttributes.add(VertexAttribute.Binormal()); } else if (attr.startsWith("TEXCOORD")) { vertexAttributes.add(VertexAttribute.TexCoords(unit++)); } else if (attr.startsWith("BLENDWEIGHT")) { vertexAttributes.add(VertexAttribute.BoneWeight(blendWeightCount++)); } else { throw new GdxRuntimeException("Unknown vertex attribute '" + attr + "', should be one of position, normal, uv, tangent or binormal"); } } return vertexAttributes.toArray(VertexAttribute.class); }
private VertexAttribute[] parseAttributes (JsonValue attributes) { Array<VertexAttribute> vertexAttributes = new Array<VertexAttribute>(); int unit = 0; int blendWeightCount = 0; for (JsonValue value = attributes.child; value != null; value = value.next) { String attribute = value.asString(); String attr = (String)attribute; if (attr.equals("POSITION")) { vertexAttributes.add(VertexAttribute.Position()); } else if (attr.equals("NORMAL")) { vertexAttributes.add(VertexAttribute.Normal()); } else if (attr.equals("COLOR")) { vertexAttributes.add(VertexAttribute.ColorUnpacked()); } else if (attr.equals("COLORPACKED")) { vertexAttributes.add(VertexAttribute.ColorPacked()); } else if (attr.equals("TANGENT")) { vertexAttributes.add(VertexAttribute.Tangent()); } else if (attr.equals("BINORMAL")) { vertexAttributes.add(VertexAttribute.Binormal()); } else if (attr.startsWith("TEXCOORD")) { vertexAttributes.add(VertexAttribute.TexCoords(unit++)); } else if (attr.startsWith("BLENDWEIGHT")) { vertexAttributes.add(VertexAttribute.BoneWeight(blendWeightCount++)); } else { throw new GdxRuntimeException("Unknown vertex attribute '" + attr + "', should be one of position, normal, uv, tangent or binormal"); } } return vertexAttributes.toArray(VertexAttribute.class); }
public Color read (Json json, JsonValue jsonData, Class type) { if (jsonData.isString()) return get(jsonData.asString(), Color.class); String hex = json.readValue("hex", String.class, (String)null, jsonData); if (hex != null) return Color.valueOf(hex); float r = json.readValue("r", float.class, 0f, jsonData); float g = json.readValue("g", float.class, 0f, jsonData); float b = json.readValue("b", float.class, 0f, jsonData); float a = json.readValue("a", float.class, 1f, jsonData); return new Color(r, g, b, a); } });
public Color read (Json json, JsonValue jsonData, Class type) { if (jsonData.isString()) return get(jsonData.asString(), Color.class); String hex = json.readValue("hex", String.class, (String)null, jsonData); if (hex != null) return Color.valueOf(hex); float r = json.readValue("r", float.class, 0f, jsonData); float g = json.readValue("g", float.class, 0f, jsonData); float b = json.readValue("b", float.class, 0f, jsonData); float a = json.readValue("a", float.class, 1f, jsonData); return new Color(r, g, b, a); } });
} else if (value.isString()) { if (value.name != null) name(value.name); value(value.asString()); } else if (value.isNull()) { if (value.name != null) name(value.name);
} else if (value.isString()) { if (value.name != null) name(value.name); value(value.asString()); } else if (value.isNull()) { if (value.name != null) name(value.name);
buffer.append(outputType.quoteValue(object.asString())); } else if (object.isDouble()) { double doubleValue = object.asDouble();