Note that there are some explanatory texts on larger screens.

plurals
  1. POJson service returns as HTML
    primarykey
    data
    text
    <p>I'm calling a third party JSON service</p> <pre><code>NSString* urlString = [NSString stringWithFormat:BASE_JSON_URL, address]; NSURL* urlAddressJSonUrl = [NSURL URLWithString:urlString]; dispatch_async(globalQueue, ^{ NSData* addressData = [NSData dataWithContentsOfURL:urlAddressJSonUrl]; [self performSelectorOnMainThread:@selector(resolveFromJSonResult:) withObject:addressData waitUntilDone:YES]; }); </code></pre> <p>copy&amp;paste the urlString into a browser results in status ok and I get my JSON object as dictionary. Converting <code>NSData</code> result to <code>NSDictionary</code> as follows results in nil </p> <pre><code>NSDictionary* jsonAddressResult = [NSJSONSerialization JSONObjectWithData:jsonResponseData options:NSJSONReadingAllowFragments error:&amp;error]; </code></pre> <p>also tried in <code>options</code> parameter the following: <code>kNilOptions</code> and <code>NSJSONReadingMutableContainers |NSJSONReadingAllowFragments</code> but I still got nil.</p> <p>transforming <code>NSData</code> to <code>NSString</code> reviled that the result is HTML:</p> <pre><code>(null)&lt;style&gt;body{color:#black;} span.q{color:#FF0084;} span.ns{color:#0259C4; font-weight:bold;} span.n{color:#666666;} span.at{font-weight:bold;}&lt;/style&gt;&lt;pre&gt;{ "&lt;span class="ns"&gt;places&lt;/span&gt;": { "&lt;span class="ns"&gt;place&lt;/span&gt;": [ { "&lt;span class="at"&gt;place_id&lt;/span&gt;": "&lt;span class="q"&gt;RaZZuVZQW7xqJM2P&lt;/span&gt;", "&lt;span class="at"&gt;woeid&lt;/span&gt;": "&lt;span class="q"&gt;1968212&lt;/span&gt;", "&lt;span class="at"&gt;latitude&lt;/span&gt;": &lt;span class="n"&gt;32.045&lt;/span&gt;, "&lt;span class="at"&gt;longitude&lt;/span&gt;": &lt;span class="n"&gt;34.769&lt;/span&gt;, "&lt;span class="at"&gt;place_url&lt;/span&gt;": "&lt;span class="q"&gt;\/Spain\/Tel+Aviv\/Tel+Aviv&lt;/span&gt;", "&lt;span class="at"&gt;place_type&lt;/span&gt;": "&lt;span class="q"&gt;locality&lt;/span&gt;", "&lt;span class="at"&gt;place_type_id&lt;/span&gt;": &lt;span class="n"&gt;7&lt;/span&gt;, "&lt;span class="at"&gt;timezone&lt;/span&gt;": "&lt;span class="q"&gt;Asia\/Jerusalem&lt;/span&gt;", "&lt;span class="at"&gt;_content&lt;/span&gt;": "&lt;span class="q"&gt;Madrid, Madrid, Spain&lt;/span&gt;", "&lt;span class="at"&gt;woe_name&lt;/span&gt;": "&lt;span class="q"&gt;Madrid&lt;/span&gt;" } ], "&lt;span class="at"&gt;query&lt;/span&gt;": "&lt;span class="q"&gt;Madrid, Spain&lt;/span&gt;", "&lt;span class="at"&gt;total&lt;/span&gt;": &lt;span class="n"&gt;1&lt;/span&gt; }, "&lt;span class="at"&gt;stat&lt;/span&gt;": "&lt;span class="q"&gt;ok&lt;/span&gt;" }&lt;/pre&gt; </code></pre> <p>how can I transform this to JSON or better yet extract the data I need?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload