Jeisson Posted September 28, 2015 Share Posted September 28, 2015 (edited) Hello i GET with api Json, The browser interpretes the html tags in the Json, so linting is not possible. i' assume the decoding is not affected? //here I define the base url first, then $url = $base_url;$results = file_get_contents($url);echo $results;exit;//Problem is that the browser interprete the html tags inside the Json. So I cannot lint the result. Q. How do i echo tags as text only in this case? Anyway if I $json_results = json_decode($results,true); Will that be in its order and clean? how can I Lint that result? Edited September 28, 2015 by Jeisson Quote Link to comment Share on other sites More sharing options...
iarp Posted September 28, 2015 Share Posted September 28, 2015 Do you have control of the sending side, whereever $url is pointing to? Can you give us the output you see from echo $results; Quote Link to comment Share on other sites More sharing options...
scootstah Posted September 28, 2015 Share Posted September 28, 2015 You can either write to a file or use htmlspecialchars to display the raw HTML. Quote Link to comment Share on other sites More sharing options...
Jeisson Posted September 28, 2015 Author Share Posted September 28, 2015 the json is "body" : "<p></p>"; but I get echoed: "body" : " "; I think htmlspecialchars would change < to <, right? Anyway the decode dont get confused of html tags, is it so? Quote Link to comment Share on other sites More sharing options...
scootstah Posted September 28, 2015 Share Posted September 28, 2015 the json is "body" : "<p></p>"; but I get echoed: "body" : " "; I think htmlspecialchars would change < to <, right? Yes. Then you'd be able to see the HTML on your screen. The other way is to write the response to a file, and then you'd have the raw response body. $results = file_get_contents($url); file_put_contents('response.txt', $results); Anyway the decode dont get confused of html tags, is it so? json_decode() does not care about HTML. Quote Link to comment Share on other sites More sharing options...
Jeisson Posted September 28, 2015 Author Share Posted September 28, 2015 my echo wass/is only for linting. And my question here for learning. so file.txt is too clumsy in my opion. but I got the thing done with htmlspecialchars, I knew it was easy but only when known how to be done. thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.