Android Question Need parse this json using jsonparser and regex

invocker

Active Member
Hi I need to parse this json with two way one with json parser and one for regex
parse

Active
Country
Email
ID
Img
UserName
videos1 and videos2 and videos3 ..................
the id is random string


json1:
{
  "Users": {
    "RCYzpiJLRkcUfaPi7Pxu1OxGFTi2": {
      "Active": "ON",
      "Country": "country1",
      "Email": "email1",
      "ID": "RCYzpiJLRkcUfaPi7Pxu1OxGFTi2",
      "Img": "imglink1",
      "UserName": "username1",
      "videos491375": "videolink1",
      "videos748628": "videolink2"
    },
    "ZqOOX8nUSuVYI9YY9jkub22kWTP2": {
      "Active": "ON",
      "Country": "country2",
      "Email": "username2",
      "ID": "ZqOOX8nUSuVYI9YY9jkub22kWTP2",
      "Img": "imglink1",
      "UserName": "username2",
      "videos1096589": "videolink1",
      "videos12385": "videolink2",
      "videos552833": "videolink3"
      },
    "ZqOOX8nUSuVYI9YY9jkub22kWTP2": {
      "Active": "ON",
      "Country": "country3",
      "Email": "email3",
      "ID": "ZqOOX8nUSuVYI9YY9jkub22kWTP2",
      "Img": "imglink",
      "UserName": "username3",
     },
    "mJozWrOKLqgdUPpZhZfinIxiKy92": {
      "Active": "ON",
      "Country": "country4",
      "Email": "emailuser",
      "ID": "mJozWrOKLqgdUPpZhZfinIxiKy92",
      "Img": "imglink",
      "UserName": "username4",
      "videos361534": "videolink1"
    }
  }
}
 

TILogistic

Expert
Licensed User
Longtime User
Example JSON is bad
1656146413317.png

1656146448782.png

1656146524095.png
 
Upvote 1

TILogistic

Expert
Licensed User
Longtime User
json fix, remove comma
1656147414361.png


JSON:
{
  "Users": {
    "RCYzpiJLRkcUfaPi7Pxu1OxGFTi2": {
      "Active": "ON",
      "Country": "country1",
      "Email": "email1",
      "ID": "RCYzpiJLRkcUfaPi7Pxu1OxGFTi2",
      "Img": "imglink1",
      "UserName": "username1",
      "videos491375": "videolink1",
      "videos748628": "videolink2"
    },
    "ZqOOX8nUSuVYI9YY9jkub22kWTP2": {
      "Active": "ON",
      "Country": "country2",
      "Email": "username2",
      "ID": "ZqOOX8nUSuVYI9YY9jkub22kWTP2",
      "Img": "imglink1",
      "UserName": "username2",
      "videos1096589": "videolink1",
      "videos12385": "videolink2",
      "videos552833": "videolink3"
      },
    "ZqOOX8nUSuVYI9YY9jkub22kWTP2": {
      "Active": "ON",
      "Country": "country3",
      "Email": "email3",
      "ID": "ZqOOX8nUSuVYI9YY9jkub22kWTP2",
      "Img": "imglink",
      "UserName": "username3"
     },
    "mJozWrOKLqgdUPpZhZfinIxiKy92": {
      "Active": "ON",
      "Country": "country4",
      "Email": "emailuser",
      "ID": "mJozWrOKLqgdUPpZhZfinIxiKy92",
      "Img": "imglink",
      "UserName": "username4",
      "videos361534": "videolink1"
    }
  }
}

B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim jRoot As Map = parser.NextObject
Dim Users As Map = jRoot.Get("Users")
Dim ZqOOX8nUSuVYI9YY9jkub22kWTP2 As Map = Users.Get("ZqOOX8nUSuVYI9YY9jkub22kWTP2")
Dim Active As String = ZqOOX8nUSuVYI9YY9jkub22kWTP2.Get("Active")
Dim Img As String = ZqOOX8nUSuVYI9YY9jkub22kWTP2.Get("Img")
Dim Email As String = ZqOOX8nUSuVYI9YY9jkub22kWTP2.Get("Email")
Dim UserName As String = ZqOOX8nUSuVYI9YY9jkub22kWTP2.Get("UserName")
Dim Country As String = ZqOOX8nUSuVYI9YY9jkub22kWTP2.Get("Country")
Dim ID As String = ZqOOX8nUSuVYI9YY9jkub22kWTP2.Get("ID")
Dim mJozWrOKLqgdUPpZhZfinIxiKy92 As Map = Users.Get("mJozWrOKLqgdUPpZhZfinIxiKy92")
Dim Active As String = mJozWrOKLqgdUPpZhZfinIxiKy92.Get("Active")
Dim Img As String = mJozWrOKLqgdUPpZhZfinIxiKy92.Get("Img")
Dim Email As String = mJozWrOKLqgdUPpZhZfinIxiKy92.Get("Email")
Dim UserName As String = mJozWrOKLqgdUPpZhZfinIxiKy92.Get("UserName")
Dim videos361534 As String = mJozWrOKLqgdUPpZhZfinIxiKy92.Get("videos361534")
Dim Country As String = mJozWrOKLqgdUPpZhZfinIxiKy92.Get("Country")
Dim ID As String = mJozWrOKLqgdUPpZhZfinIxiKy92.Get("ID")
Dim RCYzpiJLRkcUfaPi7Pxu1OxGFTi2 As Map = Users.Get("RCYzpiJLRkcUfaPi7Pxu1OxGFTi2")
Dim Active As String = RCYzpiJLRkcUfaPi7Pxu1OxGFTi2.Get("Active")
Dim Img As String = RCYzpiJLRkcUfaPi7Pxu1OxGFTi2.Get("Img")
Dim Email As String = RCYzpiJLRkcUfaPi7Pxu1OxGFTi2.Get("Email")
Dim UserName As String = RCYzpiJLRkcUfaPi7Pxu1OxGFTi2.Get("UserName")
Dim Country As String = RCYzpiJLRkcUfaPi7Pxu1OxGFTi2.Get("Country")
Dim videos491375 As String = RCYzpiJLRkcUfaPi7Pxu1OxGFTi2.Get("videos491375")
Dim videos748628 As String = RCYzpiJLRkcUfaPi7Pxu1OxGFTi2.Get("videos748628")
Dim ID As String = RCYzpiJLRkcUfaPi7Pxu1OxGFTi2.Get("ID")

1656147535104.png
 
Upvote 1
Top