Jump to content

Parsing JSON problem - cant access elements


Recommended Posts

Hello guys,

I am trying to parse json file with this formating:

[ [ { "region": "Albania", .... } ], [ { "region": "Austria", ... } ] ]

I am using MTA fromJson method.

Whenever I want to get element by json[1].region I correctly get "Albania". Bud when I try json[2].region I get error. 

I will be glad for any help. Thanks!

[
    [{
        "region":"Albánie",
        "male":["Aleks","Alesandro","Aron","Enrik","Flavio","Luis","Noel","Alban","Andi","Endri","Ermir","Arlind","Glen","Daniel","Erion","Lorik","Edi","Saimir","Vullnet","Orgest","Roland","Ferdinand","Neritan","Gazmir","Gersi","Genci"],
        "female":["Alesia","Anamaria","Greis","Klea","Sara","Sidorela","Uendi","Armela","Megi","Sindi","Drita","Albana","Kejsi","Adea","Anila","Suzana","Loreta","Alma","Arnisa","Adea","Besa","Adea","Dorina","Elvira","Entela","Enkelejda"],
        "surnames":["Bogdani","Dervishi","Dukagjini","Dushku","Frasheri","Gjoni","Gurakuqi","Hoxha","Leka","Loshi","Prifti","Baku","Kola","Zane","Musaj","Agolli","Brahimi","Kodra","Osmani","Myftiu","Xhafa","Dedja","Duro","Demiri","Shyti"]
    }],
    [{
        "region":"Argentina",
        "male":["Agustín","Sebastian","Nicolas","Lautaro","Tomas","Lucas","Joaquín","Santiago","Federico","Juan","Juan Pablo","Andres","Thiago","Benjamín","Bautista","Franco","Francisco","Matías","Gabriel","Martín","Marcelo","Pablo","Gustavo","Hernan"],
        "female":["Sofía","Isabella","Jazmín","Mia","Juana","Martina","Morena","Uma","Lucía","María","Victoria","Laura","Agustina","Lucrecia","Florencia","Emma","Pamela","Cecilia","Carolina","Mariana","Luciana","Patricia"],
        "surnames":["Gonzalez","Rodríguez","Gomez","Fernandez","Lopez","Díaz","Martínez","Perez","García","Sanchez","Romero","alvarez","Torres","Ruiz","Ramírez","Flores","Acosta","Medina","Suarez","Herrera","Aguirre","Gimenez","Molina","Castro","Rojas","Ortiz","Nuñez","Juarez","Ríos","Godoy","Moreno","Peralta","Castillo","Ledesma","Ojeda","Villalba","Hernandez","Ramos","Arias","Maidana","Moyano","Campos","Soto","Montenegro","Leguizamon","Blanco"]
    }]
]
Edited by Killbean
Link to post
  • Moderators

Should look like this:

[ [ { "region": "Albania" }, { "region": "Austria" } ] ]

 

- Put an extra [ ] around your json.

  • Like 1
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...