Android Question JSON Parsing Problems

marab

Member
Licensed User
Longtime User
hi every body!
i have a wordpress website! and i have installed json api plugin on it
now when i get posts from http://www.quickapp.ir/wp-json/posts
i gave this:
B4X:
[{"ID":5,"title":"\u0648\u0631\u0632\u0634 \u0630\u0647\u0646","status":"publish","type":"post","author":{"ID":1,"username":"QuickApp","name":"QuickApp","first_name":"","last_name":"","nickname":"QuickApp","slug":"quickapp","URL":"","avatar":"http:\/\/1.gravatar.com\/avatar\/5341a0dbc7cbc922ef9783494504ea03?s=96","description":"","registered":"2014-08-16T15:42:04+00:00","meta":{"links":{"self":"http:\/\/www.quickapp.ir\/wp-json\/users\/1","archives":"http:\/\/www.quickapp.ir\/wp-json\/users\/1\/posts"}}},"content":"<p>\u0648\u0631\u0632\u0634 \u0630\u0647\u0646 \u0646\u0633\u062e\u0647 1.7 \u0627\u0632 \u0647\u0645 \u0627\u06a9\u0646\u0648\u0646 \u062f\u0631 \u0628\u0627\u0632\u0627\u0631<\/p>\n","parent":0,"link":"http:\/\/www.quickapp.ir\/2014\/08\/16\/%d9%88%d8%b1%d8%b2%d8%b4-%d8%b0%d9%87%d9%86\/","date":"2014-08-16T15:45:34+00:00","modified":"2014-08-16T17:09:28+00:00","format":"standard","slug":"%d9%88%d8%b1%d8%b2%d8%b4-%d8%b0%d9%87%d9%86","guid":"http:\/\/www.quickapp.ir\/?p=5","excerpt":"<p>\u0648\u0631\u0632\u0634 \u0630\u0647\u0646 \u0646\u0633\u062e\u0647 1.7 \u0627\u0632 \u0647\u0645 \u0627\u06a9\u0646\u0648\u0646 \u062f\u0631 \u0628\u0627\u0632\u0627\u0631<\/p>\n","menu_order":0,"comment_status":"open","ping_status":"open","sticky":false,"date_tz":"UTC","date_gmt":"2014-08-16T15:45:34+00:00","modified_tz":"UTC","modified_gmt":"2014-08-16T17:09:28+00:00","meta":{"links":{"self":"http:\/\/www.quickapp.ir\/wp-json\/posts\/5","author":"http:\/\/www.quickapp.ir\/wp-json\/users\/1","collection":"http:\/\/www.quickapp.ir\/wp-json\/posts","replies":"http:\/\/www.quickapp.ir\/wp-json\/posts\/5\/comments","version-history":"http:\/\/www.quickapp.ir\/wp-json\/posts\/5\/revisions"}},"featured_image":{"ID":6,"title":"Nexus5","status":"inherit","type":"attachment","author":{"ID":1,"username":"QuickApp","name":"QuickApp","first_name":"","last_name":"","nickname":"QuickApp","slug":"quickapp","URL":"","avatar":"http:\/\/1.gravatar.com\/avatar\/5341a0dbc7cbc922ef9783494504ea03?s=96","description":"","registered":"2014-08-16T15:42:04+00:00","meta":{"links":{"self":"http:\/\/www.quickapp.ir\/wp-json\/users\/1","archives":"http:\/\/www.quickapp.ir\/wp-json\/users\/1\/posts"}}},"content":"<p class=\"attachment\"><a href='http:\/\/www.quickapp.ir\/wp-content\/uploads\/2014\/08\/Nexus5.png'><img width=\"300\" height=\"264\" src=\"http:\/\/www.quickapp.ir\/wp-content\/uploads\/2014\/08\/Nexus5-300x264.png\" class=\"attachment-medium\" alt=\"Nexus5\" \/><\/a><\/p>\n","parent":5,"link":"http:\/\/www.quickapp.ir\/2014\/08\/16\/%d9%88%d8%b1%d8%b2%d8%b4-%d8%b0%d9%87%d9%86\/nexus5\/","date":"2014-08-16T15:45:01+00:00","modified":"2014-08-16T15:45:01+00:00","format":"standard","slug":"nexus5","guid":"http:\/\/www.quickapp.ir\/wp-content\/uploads\/2014\/08\/Nexus5.png","excerpt":null,"menu_order":0,"comment_status":"open","ping_status":"open","sticky":false,"date_tz":"UTC","date_gmt":"2014-08-16T15:45:01+00:00","modified_tz":"UTC","modified_gmt":"2014-08-16T15:45:01+00:00","meta":{"links":{"self":"http:\/\/www.quickapp.ir\/wp-json\/media\/6","author":"http:\/\/www.quickapp.ir\/wp-json\/users\/1","collection":"http:\/\/www.quickapp.ir\/wp-json\/media","replies":"http:\/\/www.quickapp.ir\/wp-json\/media\/6\/comments","version-history":"http:\/\/www.quickapp.ir\/wp-json\/media\/6\/revisions","up":"http:\/\/www.quickapp.ir\/wp-json\/media\/5"}},"terms":[],"source":"http:\/\/www.quickapp.ir\/wp-content\/uploads\/2014\/08\/Nexus5.png","is_image":true,"attachment_meta":{"width":535,"height":471,"file":"2014\/08\/Nexus5.png","sizes":{"thumbnail":{"file":"Nexus5-150x150.png","width":150,"height":150,"mime-type":"image\/png","url":"http:\/\/www.quickapp.ir\/wp-content\/uploads\/2014\/08\/Nexus5-150x150.png"},"medium":{"file":"Nexus5-300x264.png","width":300,"height":264,"mime-type":"image\/png","url":"http:\/\/www.quickapp.ir\/wp-content\/uploads\/2014\/08\/Nexus5-300x264.png"}},"image_meta":{"aperture":0,"credit":"","camera":"","caption":"","created_timestamp":0,"copyright":"","focal_length":0,"iso":0,"shutter_speed":0,"title":""}}},"terms":{"category":[{"ID":1,"name":"\u062f\u0633\u062a\u0647\u200c\u0628\u0646\u062f\u06cc \u0646\u0634\u062f\u0647","slug":"%d8%af%d8%b3%d8%aa%d9%87%e2%80%8c%d8%a8%d9%86%d8%af%db%8c-%d9%86%d8%b4%d8%af%d9%87","description":"","parent":null,"count":1,"link":"http:\/\/www.quickapp.ir\/category\/%d8%af%d8%b3%d8%aa%d9%87%e2%80%8c%d8%a8%d9%86%d8%af%db%8c-%d9%86%d8%b4%d8%af%d9%87\/","meta":{"links":{"collection":"http:\/\/www.quickapp.ir\/wp-json\/taxonomies\/category\/terms","self":"http:\/\/www.quickapp.ir\/wp-json\/taxonomies\/category\/terms\/1"}}}]}}]



when i used json example codes for it i give some error can you give me a code that works on it?!?!
please?!

tnx for reading
 

barx

Well-Known Member
Licensed User
Longtime User
Are you using .NextArray?
 
Upvote 0

marab

Member
Licensed User
Longtime User
this is example code:
B4X:
    'parse the json file
    Dim JSON As JSONParser
    Dim Map1 As Map
    JSON.Initialize(File.ReadString(File.DirAssets, "example.json"))
    Map1 = JSON.NextObject
    Dim m As Map 'helper map for navigating
    Dim MenuItems As List
    m = Map1.Get("menu")
    m = m.Get("popup")
    MenuItems = m.Get("menuitem")
    For i = 0 To MenuItems.Size - 1
        m = MenuItems.Get(i)
        Log(m.Get("value"))
    Next
  
    'generate JSON
    Dim Data As List
    Data.Initialize
    Data.Add(1)
    Data.Add(2)
    Data.Add(3)
    Data.Add(Map1) 'add the previous map loaded from the file.
    Dim JSONGenerator As JSONGenerator
    JSONGenerator.Initialize2(Data)
    Msgbox(JSONGenerator.ToPrettyString(2), "")

i must change what to what!?
sorry but i became confused of this json because i cant understand thease text in json
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…