Json Objects fool me...

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
SamCCB
Kobold
Posts: 18
Joined: Wed Feb 26, 2020 10:02 am

Json Objects fool me...

Post by SamCCB »

Well,
I had a table :
[
{
"Titre":"Araign\u00e9e",
"Type":"Grosse",
"Terrain":"Non-arctique",
"Frequence":"Commun",
"Intelligence":"Animale (1)",
"Alignement":"Neutre",
"Classe d'Armure":"6",
"DVIE":"3 +3",
"TACO":"17",
"Nombre d'attaques":"1",
"DEGATT":"1-6",
"ATTSPEC":"Poison",
"DEFSPEC":"Aucune",
"RESMAG":"Aucune",
"Taille":"M"
},
{
"Titre":"Orque",
"Type":"Orque",
"Terrain":"Terre ferme",
"Frequence":"Commun",
"Intelligence":"Moyenne (8-10)",
"Alignement":"Loyal Mauvais",
"Classe d'Armure":"6 (10)",
"DVIE":"1",
"TACO":"19",
"Nombre d'attaques":"1",
"DEGATT":"1-8 (selon l'arme), 1-10 (selon l'arme)",
"ATTSPEC":"Aucune",
"DEFSPEC":"Aucune",
"RESMAG":"Aucune",
"Taille":"M"
},
{
"Titre":"Gobelin",
"Type":null,
"Terrain":"Tous sauf les r\u00e9gions arctiques",
"Frequence":"Peu commun",
"Intelligence":"De faible \u00e0 moyenne (5-10)",
"Alignement":"Loyal Mauvais",
"Classe d'Armure":"6 (10)",
"DVIE":1,
"TACO":20,
"Nombre d'attaques":1,
"DEGATT":"1-6 (selon l'arme employ\u00e9e)",
"ATTSPEC":"Aucune",
"DEFSPEC":"Aucune",
"RESMAG":"Aucune",
"Taille":"P"
},
{
"Titre":"Grenouille",
"Type":"G\u00e9ante",
"Climat\/Terrain":"Eau douce",
"Frequence":"Peu courante",
"Intelligence":"Aucune (0)",
"Tresor":"Aucun",
"Alignement":"Neutre",
"Classe d'Armure":"7",
"DVIE":"1-3",
"TACO":"19",
"Nombre d'attaques":"1",
"DEGATT":"1-3",
"ATTSPEC":"Langue",
"DEFSPEC":"Aucune",
"RESMAG":"Aucune",
"Taille":"M"
},
{
"Titre":"Hobgobelin",
"Type":null,
"Terrain":"Tous sauf les r\u00e9gions arctiques",
"Frequence":"Peu commun",
"Intelligence":"Moyenne (8-10)",
"Alignement":"Loyal Mauvais",
"Nombre":1,
"Classe d'Armure":"5 (10)",
"Deplacemnt":9,
"DVIE":"1+1",
"TACO":19,
"Nombre d'attaques":1,
"DEGATT":"Selon l'arme employ\u00e9e",
"ATTSPEC":"Aucune",
"DEFSPEC":"Aucune",
"RESMAG":"Aucune",
"Taille":"M"
}
]
and a code :
[h: ZeMob = 1]
[h: HTMLoutput = ""]
[H: tableInfo = getTableEntry("ConvocMonstres", ZeMob)]
[H: monsterInfo = json.get(tableInfo,1)]
[H: titre = json.get(monsterInfo,"Titre")]

And a "bad argument 2" error...
What should I do for retrieving the data's ? Someone on Discord yesterday try to help me but that doesn't work...
Thank in advance.
Slowly but surely, I'm moving in MapTools, but I'm just a guy with some skills in English and old level of coding (since Basic in early 80's and macro in MS products and more recently HTML and PHP).

Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: Json Objects fool me...

Post by Merudo »

I'm confused. You say you have a table, but what you posted is a json array.

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Json Objects fool me...

Post by aliasmask »

I assumed the table entry had a json (array of objects). I'm also assuming the json is valid.

SamCCB
Kobold
Posts: 18
Joined: Wed Feb 26, 2020 10:02 am

Re: Json Objects fool me...

Post by SamCCB »

The Table return an array with objects inside. That's the problem... But with someone on Discord the problem was explained and solved. First read the array, then take the object.
Slowly but surely, I'm moving in MapTools, but I'm just a guy with some skills in English and old level of coding (since Basic in early 80's and macro in MS products and more recently HTML and PHP).

Post Reply

Return to “MapTool”