TheRealMatze Active Member Licensed User Dec 6, 2021 #1 Hi, i have a very simple json - but i´m unable to deserialize it. Everytime i run in errors, can someone help me please. My json looks like this: Code: { "base": [{ "entry": "name", "id": "1a", "info": [{ "entry": "name", "id": "1aa" }, { "entry": "name", "id": "1ab" }] }, { "entry": "name", "id": "1b", "info": [{ "entry": "name", "id": "1ba" }, { "entry": "name", "id": "1bb" }] } ] } I need all values to put it into a database. Thanks Matze
Hi, i have a very simple json - but i´m unable to deserialize it. Everytime i run in errors, can someone help me please. My json looks like this: Code: { "base": [{ "entry": "name", "id": "1a", "info": [{ "entry": "name", "id": "1aa" }, { "entry": "name", "id": "1ab" }] }, { "entry": "name", "id": "1b", "info": [{ "entry": "name", "id": "1ba" }, { "entry": "name", "id": "1bb" }] } ] } I need all values to put it into a database. Thanks Matze
DonManfred Expert Licensed User Longtime User Dec 6, 2021 #2 B4X: Dim parser As JSONParser parser.Initialize(<text>) Dim root As Map = parser.NextObject Dim base As List = root.Get("base") For Each colbase As Map In base Dim entry As String = colbase.Get("entry") Dim id As String = colbase.Get("id") Dim info As List = colbase.Get("info") For Each colinfo As Map In info Dim entry As String = colinfo.Get("entry") Dim id As String = colinfo.Get("id") Next Next Use this helper: http://basic4ppc.com:51042/json/index.html Upvote 2
B4X: Dim parser As JSONParser parser.Initialize(<text>) Dim root As Map = parser.NextObject Dim base As List = root.Get("base") For Each colbase As Map In base Dim entry As String = colbase.Get("entry") Dim id As String = colbase.Get("id") Dim info As List = colbase.Get("info") For Each colinfo As Map In info Dim entry As String = colinfo.Get("entry") Dim id As String = colinfo.Get("id") Next Next Use this helper: http://basic4ppc.com:51042/json/index.html
TheRealMatze Active Member Licensed User Dec 6, 2021 #3 Oh, there is a helper And i try for hours... Thank you DonManfred! Upvote 0
DonManfred Expert Licensed User Longtime User Dec 6, 2021 #4 TheRealMatze said: Oh, there is a helper Click to expand... Since YEARS Since 2013 to be honest: JsonTree - Tool to help with JSON parsing (B4A / B4J) JsonTree is a tool that helps developers to parse and understand JSON strings. It shows the data structure in a TreeView and it also prints the code (B4J / B4A) required in order to extract the data from the string. Note that variables in the generated code are based on the JSON fields. It may... www.b4x.com Upvote 0
TheRealMatze said: Oh, there is a helper Click to expand... Since YEARS Since 2013 to be honest: JsonTree - Tool to help with JSON parsing (B4A / B4J) JsonTree is a tool that helps developers to parse and understand JSON strings. It shows the data structure in a TreeView and it also prints the code (B4J / B4A) required in order to extract the data from the string. Note that variables in the generated code are based on the JSON fields. It may... www.b4x.com