我正在加载一个gltf资产(基本上是一个大的json文件)。我想迭代其中的一个字段,即我正在做这个:
let data = fs::read_to_string("Assets/werewolf_animated.gltf").expect("Unable to read file");
let json: serde_json::Value =
serde_json::from_str(&data).expect("JSON was not well-formatted");
for skin in json["skins"].into()
{
println!("{:?}", skin["inverseBindMatrices"]);
}
但是显然Rust不能推断类型,我得到了以下错误信息:
println!("{:?}", skin["inverseBindMatrices"]);
| ^^^^ cannot infer type
我该如何迭代遍历皮肤json数组中的每个条目?
就这个特定字段而言,它在json文件中的外观如下:
"skins" : [
{
"inverseBindMatrices" : 5,
"joints" : [
64,
53,
52,
51,
2,
],
"name" : "Armature"
}
],