w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to separate JSON response in iphone
You need to parse the JSON Response String, you can use any JSON parser like: https://github.com/stig/json-framework/ And in your code do: NSString *strResp = [[NSString alloc]initWithData:respData encoding:NSUTF8StringEncoding]; NSDictionary *ResponseDictionary = [strResp JSONValue]; NSString * pSerial = (NSString*)[ResponseDictionary objectForKey:@"pserial"];

Categories : Iphone

Create separate storyboards for iphone 4 and 5
You have tried to define a method inside application:didFinishLaunchingWithOptions:: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { -(void)initializeStoryBoardBasedOnScreenSize { // ... your code ... } return YES; } This is not what you want and btw. nested functions (or methods) are not supported in Objective-C. What you probably meant is to define a method and call it inside application:didFinishLaunchingWithOptions:: -(void)initializeStoryBoardBasedOnScreenSize { // ... your code ... } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self initializeStoryBoardBasedOnScreenSize]; return YES; }

Categories : Iphone

Deserialize multiple JSON arrays into separate C# datasets/datatables using JSON.net (newtonsoft)
This doesn't answer the question exactly because I personally don't see why you would want to deserialize into datasets when the json.NET model is more oriented around deserializing into objects. Here it is; public class TheJson { public string status { get; set; } public client[] clients { get; set; } public dossier[] dossiers { get; set; } } public class client { public string ClientID { get; set; } public string Fullname { get; set; } public bool Inactive { get; set; } } public class dossier { public string CreateDate { get; set; } public string DossierName { get; set; } } With those definitions it's as simple as; TheJson clientsAndDossiers = JsonConvert.DeserializeObject<TheJson>(_jsonresp); Now with regard to your last comment, to ap

Categories : C#

How to parse a JSON response when type is also coming in response
The usual way to deal with data items which could be any of a small known number of types is to use a tagged union. In Java, you'd write one something like this: // CREATE TABLE dataFromJson (type ENUM('INT', 'BOOLEAN', 'STRING'), // intval INT, boolval INT, stringval LONGTEXT); class DataItem { public enum Type { INT, BOOLEAN, STRING }; public Type m_type; public int m_int; public bool m_boolean; public String m_string; public PreparedStatement toInsertQuery(Connection conn) { PreparedStatement ps = conn.prepareStatement("INSERT INTO dataFromJson VALUES (?, ?, ?, ?)"); ps.setString(1, m_type.toString()); if (m_type==INT) ps.setInt(2, m_int); else ps.setObject(2, null); if (m_type==BOOLEAN) ps.setBoolean(3

Categories : Android

iPhone app response to device orientation change
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { //Do what you want here } this method is called when device changes his orientation..

Categories : Iphone

Are separate request and response XSDs required for an XML rest API?
Yes. if all of the 4 messages have different formats (which most likely are) then yes, you need 4 definitions too. now, XSDs can be merged. The bigger question is whether they should. XSDs should be mered in one when they share some common sub-component. if all the components are independent then they should better be independent too. But again if you have compelling reasons to merge your 4 XSDs then technically you can. ref: validate two xml with a single schema https://www.google.co.in/search?q=merge+xsd

Categories : Xml

Android couldnot parse http response where as iphone can
Whereas your current problem can't be solved without the full code, I highly recommend you use https://github.com/octo-online/robospice, not only will it handle everything for you, it adds caching and other features

Categories : Java

Email to SMS Gateway Verizon iPhone response goes to phone only
I saw the same issue while using Amazon SES to send emails to Verizon customers. Amazon did a bunch of digging and found that it was just an error with the way Verizon's gateway is set up. I don't think there was ever a resolution. https://forums.aws.amazon.com/thread.jspa?threadID=59605

Categories : Iphone

How to avoid delay of webservice(ASIHTTPRequest) response in iPhone?
We cant control the internet speed due to the different network provider or environment when the client is using your app. But you can put your web-services to run in background without effecting your main function. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ //code for webservices calling dispatch_async(dispatch_get_main_queue(), ^{ //functions after your webservices done, for example reload the table or hide the loading bar. }); });

Categories : Iphone

Display different parts of JQuery Ajax response in separate DIVs
Using JSON would be a better option, as others in the comments have pointed out. if($result) { $sql = "SELECT * FROM image WHERE auditID = '$audit_id'"; $result = mysqli_query($mysqli,$sql) or die(mysqli_error($mysqli)); $numRows = mysqli_num_rows($result); $my_id = mysqli_insert_id($mysqli); $output_array = array( 'my_id' => $my_id, 'grade' => $grade, 'numRows' => $numRows ); } //etc... Then at the end of the file: echo json_encode($output_array); Now you do the HTML formatting in your AJAX success function: jQuery.ajax({ type: "POST", url: "response.php", dataType: "json", data: $('#test_form').serialize(), success:function(response){ $

Categories : Javascript

Cannot see the Restangular response data set in my chrome developer tools... is it bc my JSON contains nested JSON?
I'm the creator of Restangular. So, when you're doing a getList, Restangular expects to get an Array as the response. In your case, when you're getting a list and the path is availableCourses, you're returning a string (the title) which has properties. So you're creating a "special" string with properties, it's not really common, nor compatible with Restangular. If you want to get the list of all available courses, you need to return an array as the new response. So, what's the exact response from the server when you do the getList? If you giv eme that, I'll be able to help you easier on how to create this response extarctor. Also take a look to this MongoLab example :), maybe It'll help you. http://plnkr.co/edit/d6yDka?p=preview Bests!

Categories : Angularjs

Ajax json always returning error although json format in response is correct
Indeed the string <!-- 0.375s --> is breaking your code. Try to find out where it is comming from. Some steps: What layout are you using to render this? Try debug($this->layout) in your Controleler to see which on it is. This may very well be in there since I don't see you setting the layout to ajax for example. Cake has this ajax layout, which essentially is an empty layout. It should not contain anything more than echo $content_for_layout; in CakePHP 1.3. Check and be sure that your is "spitted out" UTF-8 encoded. This is a must for JSON. Try replacing your current view code with echo json_encode($response); or to keep the trilateral check: echo isset($response) ? json_encode($response) : ''; The JavaScriptHelper will to the same thing anyway. This "strange string" may very we

Categories : Ajax

how to send media file to wcf rest json service and get string return response in json format
To send a media file (or any arbitrary file, for that matter) to WCF, you need to have an operation where the only parameter in the request body is of type Stream. That means that you can have other parameters to the operation, but they need to be passed via the URI (using the UriTemplate property of the [WebInvoke] attribute) - see more information in the post at http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-arbitrary-data.aspx. In your example, you'd have something like the code below: [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "RegisterUser?emailId={EmailID}&name={Name}&mobile={Mobile}&IMEI={IMEI}", BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat= WebMessageFormat.Json, ResponseFor

Categories : Android

Receving send json to server and recive json response
It may be already answered in How to decode JSON values in my Android Aplication? BUT, if you want to parse JSON Data from the App to the Webserver you may want to use the flag true. $post = json_decode(filter_input(INPUT_POST, 'data'), true); foreach ($post as $obj) { echo $obj["yourobj"]; } If you have problems parsing the data from the webserver to the app, force it to be an object by using json_encode($data, JSON_FORCE_OBJECT); if you want to parse an array use json_encode(array("data", $yourdata)); Please explain what you want and the error you get for a proper solution matching your case.

Categories : Android

Getting 411 response code while getting JSON Response
There are a few things that don't look quite right here. I would recommend trying this: httpConnection.setRequestMethod("POST"); URLEncodedPostData postData = new URLEncodedPostData("UTF-8", false); postData.append("username", user); postData.append("password", password); byte[] postDataByte = postData.getBytes(); httpConnection.setRequestProperty("Authorization", "bearer"+"ZWOu3HL4vwaOLrFAuEFqsxNQf6ka"); httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); httpConnection.setRequestProperty("Content-Length", String.valueOf(postDataByte.length)); OutputStream out = httpConnection.openOutputStream(); DataOutputStream dos = new DataOutputStream(out); out.write(postDataByte); out.flush(); int statusCode = httpConnection.getResponseCode();

Categories : Java

Parsing JSON server response into JSON Array
This should be it. So you're probably trying to get JSONObject instead of String inside the results aarray. JSONObject responseObject = new JSONObject(responseString); JSONArray resultsArray = responseObject.getJSONArray("results"); for (int i=0; i<resultsArray.length(); i++) String resultString = resultsArray.getString(i);

Categories : Java

Unable to access AJAX JSON response, despite setting content type and datatype, parseJSON returns error however still 'valid' JSON
The right answer was established in the comments: On .fail, jQuery returns a jqXHR object, instead of data. The data you're looking for is in the responseText property of this object. .fail(function(jqXHR) { var json = $.parseJSON(jqXHR.responseText); console.log(json); });

Categories : Javascript

Retrieving Clean JSON from Response::json
Your syntax is wrong. Instead of die(Response::json(array('message': 'Success', 'status': 200', 'redirect_url': ''), 200);); use die(Response::json(array('message'=> 'Success', 'status'=> 200', 'redirect_url'=> ''), 200));

Categories : Ajax

Can we use two header files in two separate .mm files in same project in iPhone
You've included same file in your project twice. It's possible that another library (such as sharekit) included it for you, doublecheck the files sharekit includes and remove one copy of that file and things should compile.

Categories : IOS

iOS JSON Response twice, JSON Null
Build the output array, then output your json. What might be happening is you are sending valid json the first time, and then as you continue to ech, it becomes invalid because you strings like: {test: 1}{hello: 2} isn't valid json. $output = array(); //create a while loop that places the returned data into an array while ($list = mysql_fetch_assoc($query)){ //store the returned data into a variable $output[] = $list; } //encode the returned data in JSON format echo json_encode($output);

Categories : PHP

i am not getting json response, instead getting json object.. how to fix it
$.getJSON doesn't return the JSON. It is asynchronous. Calling return in the callback won't change this. Instead, use this: var JsonHandler = function(callback){ return { json : function(url){ return $.getJSON(url, callback); } } }; (function ($) { var path = "js/data.json"; var getJson = new JsonHandler(function(data){console.log(data)}); getJson.json(path); })(jQuery);

Categories : Jquery

Separate JSON string into variable in android
It looks like you're making assumptions about what data each object in your array will have. One of those objects does not have every piece of data and this is throwing an error. I'm guessing your error is in one of these lines: String id = jsonObj1.getString(TAG_ID); String nameFirst1 = jsonObj1.getString(TAG_FIRSTNAME); String nameLast1 = jsonObj1.getString(TAG_LASTNAME); String emailAddress1 = jsonObj1.getString(TAG_EMAIL); String streetAddress1 = jsonObj1.getString(TAG_ADDRESS); String phone1 = jsonObj1.getString(TAG_PHONE); Since you're not seeing anything printed, set a breakpoint and verify that each piece of data is actually there when you first enter your for loop. In addition, I would recommend doing some defensive coding and using has() to verify that the jsonObject actually

Categories : Java

XML to JSON using Ruby and save it for separate file
I'm assuming you want to print the listing blocks to individual files as JSON. If you have access to 'active_support/core_ext' and 'nokogiri', and you aren't too concerned about how your XML is converted to JSON, you can just do: require 'active_support/core_ext' require 'nokogiri' xml = Nokogiri::XML(File.read "yourfile") xml.search("//listing").each do |l| filename = l.at_xpath("id").content File.open(filename + '.json', 'w') do |file| file.print Hash.from_xml(l.to_xml).to_json end end

Categories : Ruby

Sending JSON files to iPhone for iOS app testing
You can put the file in the application bundle (ensure it's there in XCode, under the Copy Bundle Resources section on the Build Phases tab for the project), then access the file directly with no path, with simply default.json. However, any files in the application bundle are read only. Alternatively, if you wish to be able to update the file, your app should typically copy the file from the application bundle to the documents folder on first launch, and then access the copy in the documents folder from then on. (Hint: If the file doesn't exist in the documents folder, copy it from the application bundle.) When distributing an app, only the files included in the application bundle are delivered. When run on a device from XCode, only the application bundle is copied to the device, and all

Categories : Iphone

How to parse json ki typical format in iphone
Sample Code : NSDictionary *content = [[[[yourJSONResponseDict objectForKey:@"data"] objectForKey:@"items"] objectAtIndex:0] objectForKey:@"content"]; NSLog(@"Content :: %@",content); Explanation : //1. This will give you the "Value" for key "data". NSDictionary *data = [yourJSONResponseDict objectForKey:@"data"]; //2. This will give you the "Value" for key "items" which is inside "data" Dictionary. NSArray *items = [data objectForKey:@"items"]; //3. This will give you the First Object of "items" Array which is a Dictionary. NSDictionary *itemObject = [items objectAtIndex:0]; //4. This will give you your Final Component named "Content" which is a Dictionary also. NSArray *content = [itemObject objectForKey:@"content"];

Categories : Iphone

JSON Parse error - iPad/iPhone Only
url: '/beta/images/loadImages', type: 'POST' If you are just loading something (especially on page load), why use POST? Use GET instead. You are getting the JSON parse error because you aren't returning valid JSON (you are returning html/xml). The only possible explanation is you have some server side logic that dictates if browser == mobile return html/xml else return JSON

Categories : PHP

PHP JSON : Read contact details from Yahoo JSON response Contact Object
Try this: <?php $json = '{"contacts":{"start":0,"count":5,"total":110,"contact":[{"isConnection":false,"id":16777250,"fields":[{"id":16777292,"type":"yahooid","value":"ahmed_love7353","editedBy":"OWNER","categories":[]},{"id":16777291,"type":"name","value":{"givenName":"ahmed","middleName":"","familyName":"_love","prefix":"","suffix":"","givenNameSound":"","familyNameSound":""},"editedBy":"OWNER","categories":[]}]},{"isConnection":false,"id":52,"fields":[{"id":124,"type":"email","value":"15688708283341592078@mail.orkut.com","editedBy":"OWNER","categories":[]}]},{"isConnection":false,"id":16777271,"fields":[{"id":16777343,"type":"email","value":"abcdall4u@gmail.com","editedBy":"OWNER","categories":[]}]},{"isConnection":false,"id":31,"fields":[{"id":69,"type":"yahooid","value":"supriya_9

Categories : PHP

Make iPhone to send URLEncoded string instead of JSON
This works perfect and internally converts the json in a Request object that, once in the Controller, I can get straightforward with $this->getRequest()->get('key1') or get('key2') obtaining some well formed PHP objects with no additional work. Symfony does not internally convert your json in a Request object! If you want one way for working with data you need to send data with only one type (json or x-www-url-encoded). I wrote you in the previous question that you can encode iOS to send data with x-www-url-encoded but you can also send JSON in jQuery.post and from iOS. And then you must implement only: $data = json_decode($this->getRequest()->getContent()); To send JSON data in your JS you need next code: $.ajax({ type: "POST", url: myURL, data: JSON.strin

Categories : Objective C

How can I permanently modify a JSON object on a separate file with JavaScript?
JavaScript cannot modify files on the server. You'll need a server-side language (like PHP) to do it. Some Points: What's the difference between server-side and client-side programming? A file that contains JSON should end with the .json extension. dataType is the type of data you're expecting. contentType is the type of data you're transferring (that's what you want).

Categories : Javascript

iPhone downloading many small JSON files and storing in DB asynchronously
For encoding you can, for example, use gzip-compressed data in your http response that will be unpacked by ios automatically without the need to code anything. Just add "Content-Encoding: gzip" to your http response on the server side. On iOS, i think NSURLRequest accepts gzip encoding by default, or you can set [request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"] Of course you can download the JSONS in the background. A good source for information and example code is here http://iosdevelopmentjournal.com/blog/2013/01/27/running-network-requests-in-the-background/

Categories : Iphone

Is hosting JSON files used by my iphone app on 3rd party servers a good idea?
Why don't you use a free service like StackMob to build your database online? This way you can update the data whenever you want. You might even build an app or a script to update the data easily and automatically.

Categories : IOS

How to take particular value from json response in php
Try this, <?php $json='[{"Obj" : { "ID":"11", "NAME":"XYZ", "GENDER":"M" } }]'; $jsonArray=json_decode($json); echo $jsonArray[0]->Obj->ID; ?>

Categories : PHP

Why am I not getting my json response?
There is not enough information for me to debug the output from your URL - however I think you should be able to solve that yourself by adding this to the bottom of your page:- <?php var_dump(file_get_contents($req)); ?> In addition to this, none of your form elements possess a name attribute so nothing is actually being posted to your script. Here is a modified version of your form which includes the name attributes on each field:- <form action="smarty-geocode.php" name="" method="post"> <input id="addresses" name="addresses" type="hidden" value=""> Street Address <input id="street" name="street" type="textbox" value="" class="address"> <br /> City <input id="city" name="city" type="textbox" value="" class="addr

Categories : PHP

JSON response from URL
Open a modern browser like Firefox or chrome and open the developer tools. Navigate to the page that contains the above code and monitor the "network" tab to see the related http request triggered via ajax. You can then see the request + response including header, body and return codes. This should help to figure out the problem.

Categories : HTML

Response json data
Replace: success:function(feeds) { alert(feeds); } To success:function(feeds) { var obj = jQuery.parseJSON(feeds); console.log(obj); } Note: now you can use var obj because when you get the response from Rest service it is a json string so you have to convert it into object.

Categories : Java

Parsing JSON response in c#
Simply put, you need to use a JSON parser. Personally I like Newtonsoft.Json and it is what I will use in this example. The first step is converting the byte[] to a sequence of characters, either a string object or a TextReader. The second step is to pass this information to the parser. So, in your case, the code would look something like this: JToken parsedToken; using (var responseReader = new StreamReader(new MemoryStream(response))) { parsedToken = JToken.ReadFrom(responseReader); } The parsedToken object can then be used to extract whatever data you need. (See the documentation for information on extracting data from a JToken object.) Note that WebClient.UploadValues() discards the information regarding the response entity's character encoding. StreamReader will use UTF-

Categories : C#

Getting node from Json Response
def slurp = new groovy.json.JsonSlurper().parseText(jsonStr) slurp.each{key, val -> val.each{ assert "Title" in it.keySet() } } where jsonStr represents the above json response in string. (enclosed in '''yourJson''')

Categories : Json

what is wrong with json response
One way to have a good sleep is to use requests: import requests import simplejson response = requests.get("https://api.stackexchange.com/2.1/answers?order=desc&sort=activity&site=stackoverflow") response_json = simplejson.loads(response.text) print response_json No errors, just works.

Categories : Python

JSON response using express
I would suggest using a library like async. Instead of nested callbacks as askkirati suggested. var express = require('express') , async = require('async') , http = require('http') , mysql = require('mysql'); // <---- HERE var app = express(); var connection = mysql.createConnection({ host: 'localhost', user: 'root', password: "root", database: 'DB' }); connection.connect(); // <---- AND HERE // all environments app.set('port', process.env.PORT || 7002); app.get('/',function(request,response){ var first, second; async.series( [ // Get the first table contents function ( callback ) { connection.query('SELECT * FROM table1', function(err, rows, fields) { console.log('Connection r

Categories : Node Js

how to get json response in golang
You need upper case property names in your structs in order to be used by the json packages. Upper case property names are exported properties. Lower case property names are not exported. You also need to pass the your data object by reference (&data). package main import "os" import "fmt" import "net/http" import "io/ioutil" import "encoding/json" type tracks struct { Toptracks []toptracks_info } type toptracks_info struct { Track []track_info Attr []attr_info } type track_info struct { Name string Duration string Listeners string Mbid string Url string Streamable []streamable_info Artist []artist_info Attr []track_attr_info } type attr_info struct { Country string Page string Pe

Categories : Go



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.