php - remove un necessary hierchy from json output -
I am creating an administrator backend for the Android app. My code provides a JSN output that the Android developer uses in its app. The developer asked me whether it is possible to reduce hierarchy level in JSL output
Remove highlighted This is my current PHP code and Jason production is being generated I'm not sure if I made that change or if this could be possible. Is it enabled? [] 0
and instead of insert content directly inside [] data .
if ($ type == 1) // handel item display {try {$ query = "SELECT SELECT FROM CATEGORY"; $ Result = $ DBH-> Query ($ query); While ($ line = $ result- & gt; receive (PDO :: FETCH_ASSOC)) {$ cat = $ row ['category']; $ Query1 = "SELECT *" from the item is catagory = '$ cat' "; $ Value = $ DBH- & gt; Query ($ query1); If ($ line1 = $ value- & gt; get all (PDO :: FETCH_OBJ)) {$ main [] = array ('data' = & gt; array ($ line 1)); } And {$ main [] = array ('data' = & gt; array ('cat' = & gt; $ line ['category'])); }} Echo json_encode ($ main); $ Result-> CloseCursor (); // Close Database Connection Free Resource $ DBH = Faucet; } Hold (PDOException $ e) {print $ e- & gt; GetMessage (); Die (); }}
[["data": [[{"id": "2", "name "Rice", "Price": "20", "Details": "Plain Rice", "Image": "4106_R ice.jpg", "Time": "12 Minutes", "Cat": "Lunch "Item 1", "value": "32", "description": "item 1 description", "image": "1370_2", "sqqqlqilz" {"Id": "4", "name": "hello", "price": "time": "10", "catgary": "lunch", "subcut": "chicken soup" "Lunch": "lunch", "lunch", "lunch": "", "" "" "" "" "" "," image ":" "," time ":" 76 "," catagory ":" lunch "," subcut ":" "}]]]]}, {" date "{" Catagory ": {" catagory ":" test "}}
: {" catagory ":" dinner ": {" data ": {" catagory ":" soup "}}, { / Pre>
Your Jason Structure is incompatible and try this approach, the developer will be able to parse
["data": [{"id": "2", "name" "" "Time": "12 minutes", "Time": "Rice", "Value": "20", "Details": "Plain" 3 "," name ":" 3 "," name ":" 4106_rice.jpg " "Catagory": "Lunch", "Subcut": ""}, "Item 1", "Keyme ":" 32 "," description ":" Item 1 Description "," Pictures ":" L370_2 Sikeklikljlkllj. "Hello", "price": "" " "", "Description": "fgsdjfsfsdj", "picture": "", "time": "76", "cat": "lunch" {"data": {{"catagory": "soup"} } {{"Catagory": "dinner"}}}, {"data": {{{{{"{{"} ":" test ": {" data ":" subcat ":" "}}}, {" data " "}]}]}
Comments
Post a Comment