prueba
This commit is contained in:
@@ -30,9 +30,10 @@ pub fn load_card_file(path: &Path) -> anyhow::Result<EntityCard> {
|
|||||||
/// salidas de generadores que envuelven en `{"seed": {...}}`).
|
/// salidas de generadores que envuelven en `{"seed": {...}}`).
|
||||||
pub fn extract_card_from_json(raw: &str) -> anyhow::Result<EntityCard> {
|
pub fn extract_card_from_json(raw: &str) -> anyhow::Result<EntityCard> {
|
||||||
let v: serde_json::Value = serde_json::from_str(raw)?;
|
let v: serde_json::Value = serde_json::from_str(raw)?;
|
||||||
if let Ok(c) = serde_json::from_value::<EntityCard>(v.clone()) {
|
let direct_err = match serde_json::from_value::<EntityCard>(v.clone()) {
|
||||||
return Ok(c);
|
Ok(c) => return Ok(c),
|
||||||
}
|
Err(e) => e,
|
||||||
|
};
|
||||||
if let serde_json::Value::Object(map) = v {
|
if let serde_json::Value::Object(map) = v {
|
||||||
for (_, vv) in map {
|
for (_, vv) in map {
|
||||||
if let Ok(c) = serde_json::from_value::<EntityCard>(vv) {
|
if let Ok(c) = serde_json::from_value::<EntityCard>(vv) {
|
||||||
@@ -40,7 +41,9 @@ pub fn extract_card_from_json(raw: &str) -> anyhow::Result<EntityCard> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
anyhow::bail!("JSON no contiene una EntityCard válida")
|
// Propagamos el error del intento directo: es el caso típico (JSON top-level
|
||||||
|
// = EntityCard) y su mensaje apunta al campo concreto que rompió.
|
||||||
|
anyhow::bail!("JSON no contiene una EntityCard válida: {direct_err}")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Carga reglas desde un archivo JSON.
|
/// Carga reglas desde un archivo JSON.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"schema_version": 1,
|
"schema_version": 1,
|
||||||
"id": "01KQVPSMINBOOT0000000000AA",
|
"id": "01HQAR53D4M2NBV8KZTYXFGS01",
|
||||||
"lineage": null,
|
"lineage": null,
|
||||||
"label": "vps-min",
|
"label": "vps-min",
|
||||||
"provides": ["Spawn", "Journal"],
|
"provides": ["Spawn", "Journal"],
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
"genesis": [
|
"genesis": [
|
||||||
{
|
{
|
||||||
"schema_version": 1,
|
"schema_version": 1,
|
||||||
"id": "01KQVPSMINBOOT0000000001SL",
|
"id": "01HQAR53D4M2NBV8KZTYXFGS02",
|
||||||
"lineage": null,
|
"lineage": null,
|
||||||
"label": "heartbeat-sleep",
|
"label": "heartbeat-sleep",
|
||||||
"provides": [],
|
"provides": [],
|
||||||
|
|||||||
Reference in New Issue
Block a user