In the Runequest campaign I have a problem when showing json tables. I am really new to this so I can't see where is the problem. For example, with wepons, the json looks this way (I only copy a single weapon so it is not too long):
Code: Select all
[{"Nom":"Alabarda","Mains":"2H","Competence":"Estilo: Close Combat","Category":"Close Combat","Degats":"1D8+2","Type":"Yes","Portee":2.5,"Attaques par Round":"1","Recharge":"0","Munitions":"0","Enrayement":"0","Bonus/Malus":"0","Epoque":"Runequest","Notes":"Can be set against a charge ","Manoeuvres":"Atrapar","STR":7,"DEX":7,"Taille":"G","Allonge":"ML","PA":4,"PV":10,"Perce-Armure":"0","Description":"An axe head combined with a thrusting tip and a hook, mounted on a spear shaft, the halberd is a multi-purpose weapon. Halberdiers are versatile opponents that can bring any version of the weapon's attack to bear in an instant. ","Prix":"250","Monnaie":"SP","Poids":"4"},
Here is the macro call:
Code: Select all
[h:AllWeapons=getLibProperty("AllWeapons","Lib:gm")]
[frame("Weapons","temporary=0"):
{
[macro("JsonToTable@lib:gm"):AllWeapons]
}]
Code: Select all
[h:jsonarray=Macro.args]
[h:jsonarraylength=json.length(jsonarray)]
[h:jsonobject=json.get(jsonarray,0)]
[h:jsonobjectfields = json.fields(jsonobject)]
[h:jsonobjectattrib = json.get(jsonobject,"Nom")]
[h:jsonobjectlength=json.length(jsonobject)]
[h:numberOfRows = jsonarraylength]
[h:numberOfColumns = jsonobjectlength]
[h: oddRow = '#FFFFFF']
[h: evenRow = '#EEEEAA']
<html>
<head>
<title>Tableau</title>
<link rel="stylesheet" type="text/css" href="generic_css@Lib:gm"></link>
</head>
<body>
<table border="0" CELLPADDING=5 Align=center width=100%>
[for(j,0,NumberOfColumns,1,""):"<th Align=center>"+ listGet(jsonobjectfields,j)]</th>
[h:bgColor = oddRow]
[for(i,0,NumberOfRows,1,""),code:
{
[h:jsonobject=json.get(jsonarray,i)]
[if ((i/10)==floor(i/10) && i!=0),CODE :
{
[for(j,0,NumberOfColumns,1,""):"<th Align=center>"+ listGet(jsonobjectfields,j)]</th></tr>
};{}]
<tr>
[for(j, 0, NumberOfColumns, 1, ""), code:
{
<td align='center' bgcolor=[r:bgColor]><span color='black'><b>
[h:jsonobjectattrib=listGet(jsonobjectfields,j)]
[json.get(jsonobject,jsonobjectattrib)]
</td>
}]
</tr>
[h:bgColor = if(bgColor == oddRow, evenRow, oddRow)]
}]
</table>
</body>
</html>