w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
generated from a JSON response?
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

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

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

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

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

Send JSON to PHP and get a response
json_decode (depending on PHP version) defaults to returning an array, not an object. The proper way to access it would be: $output = $jsonData['firstname']; You'll also want it to return an associative array, so pass true as the second argument of json_decode. $jsonData = json_decode($input, true); What could alternately be happening is that the JSON is invalid, in which case PHP returns null. You can check for that: if ($jsonData = json_decode($input, true) === null) { // Do stuff! } else { // Invalid JSON :( }

Categories : PHP

Can't parse a JSON Response
You can use the JavaScriptSerializer, it is available for .net 3.5. Consider to use the very popular and easy Json.NET which can be installed with nu-get.

Categories : C#

looping through json response and sum value
daySum[date] += eValue; adds eValue to the current value of daySum[date]. In the event that daySum doesn't have a key with the name of date, you'll be adding together undefined and a number: > undefined + 2 NaN There's the source of your error. Now to fix it, you need to check to see if the key exists beforehand: if (date in daySum) { daySum[date] += eValue; } else { daySum[date] = eValue; } Also, don't omit var when declaring variables. You'll make them globally scoped, which isn't something you want to do with every variable.

Categories : Jquery

How to set id to a
HTMLTableRowElement elements, like all HTMLElement elements, have an id property, so: rowib.id = buttonID; ...will do it.

Categories : Javascript

UrlConection not getting JSON response
You can try android-query library, then it's easy. AQuery aq = new AQuery(this); aq.ajax("https://api.metwit.com/v2/weather/?location_lat=22.03&location_lng=75.65", JSONObject.class,new AjaxCallback<JSONObject>(){ @Override public void callback(String url, JSONObject object, AjaxStatus status) { String ret = object.toString(); System.err.println(ret); } }); This solution works fine for me.

Categories : Android

How to return a Json Response
Your JSON string is being wrapped in another JSON string. One way to return a raw JSON string is to change the output type of GetResults() to Stream instead of string. public System.IO.Stream GetResults() { string str=//Call RestServiceB which returns response as below. "query":"myquery", "results": [ {"name":"result1", "type":"suggest"}, {"name":"result2", "type":"type2"}]" WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8"; return new MemoryStream(Encoding.UTF8.GetBytes(str)); } [OperationContract ] [WebGet(UriTemplate = "getresults")] String GetResults();

Categories : C#

Get JSON response at javascript
Did you serialize your object to json format ? $.ajax({ url: //your_url, type: "POST", success: function (data) { // write your parsing code.. } }, error: function (err) { } }); exp json from w3schools.com { "people": [ { "firstName":"John" , "lastName":"Doe" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" } ] } parsing exp (in jquery ajax success function ): $.each(data.people, function (i, person) { console.log(person.firstName + " " + person.lastName) });

Categories : Javascript

Getting an error with this JSON response
A couple of problems there: In JSON, keys must be in double quotes (so must strings). Single quotes aren't allowed, and quotes are required. In JSON, the top level must always be an object or an array. You've quoted a series of property initializers, which must be inside an object. Here's the valid version of that: { "app": {"type": "app", "desc": "Application"}, "iso": {"type": "iso", "desc": "ISO Disk Image"}, "fla": {"type": "fla", "desc": "Adobe Flash Document"}, "dll": {"type": "dll", "desc": "Dynamic Link Library"} } Changes: Change all single quotes to double quotes. Put double quotes around the keys (type, desc) that didn't have them. Put the whole thing in {} so the top level is an object.

Categories : Javascript

Qt parse a json response
Looking at the documentation for QJsonDocument you can read the file into a QByteArray and then do the following: - // assuming a QByteArray contains the json file data QJsonParseError err; QJsonDocument doc = QJsonDocument::fromJson(byteArray, &err); // test for error... Then use the function on the QJsonDocument to retrieve the top level object... if(doc.isObject()) { QJsonObject obj = doc.object(); QJsonObject::iterator itr = obj.find("id"); if(itr == obj.end()) { // object not found. } // do something with the found object... } There is also a value() function in QJsonObject, so instead of using the iterator and calling find, you may simply be able to call: - QJsonValue val = obj.value("id"); Disclaimer: I present this code after having

Categories : C++

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

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

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

Receiving JSON Response
First of all, you need to use @PathParam correctly. You need to specify {json} in your url. Look at the example UPD: It's just occurred to me, you in your case you don't need to use @PathParam at all. Just put it away and it should work.

Categories : Java

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

How to access Json Response
so if you console.log data, what is in the log=? done: function (e, data) { console.log(data); $.each(data.files, function (index, file) { $('.upl').remove(); $('<p/>').text(file.name).appendTo("#phy_files"); }); }

Categories : PHP

Parse Json response
jsonObj is an array. Arrays don't have a video_source_id property. But the objects in your array do. So I believe you want jsonObj[i].video_source_id instead, i.e. "access the video_source_id property of the ith element in jsonObj". See also: Access / process (nested) objects, arrays or JSON

Categories : Javascript

How to read json response
At first glance, you are mixing data[0] and data[1] (it will display all action details from the first item in the data array) $(document).ready(function() { $.getJSON('http://services.berthojoris.com/json/baca2.php', function(data) { for(var i=0; i<data[0].actionDetails.length;i++){ document.write('Judul Halaman : '+ data[0].actionDetails[i].pageTitle+"<br>"); document.write('URL : '+ data[0].actionDetails[i].url+"<hr>"); } }); }); If you want to display all action items in data $(document).ready(function() { $.getJSON('http://services.berthojoris.com/json/baca2.php', function(data) { $.each(data, function(idx, item){ $.each(item.actionDetails, function(idx, actionDetail){ document.write('Judu

Categories : PHP

JSON response issues c#
If you are using Visual Studio 2012 and Web Tools 2012.2 or later, then there is a feature called Paste JSON As Classes where you can paste your valid JSON into the code editor and select Edit -> Paste Special -> Paste JSON As Classes to generate C# or VB.NET classes that will generate your pasted JSON structure. Read Paste JSON As Classes’ in ASP.NET and Web Tools 2012.2 for more information and instructions.

Categories : C#

SOAP response (XML) to JSON
Came up with a working solution, not any less dirty but it works and returns data in the format I want. function soapResponseToJson(xml) { var json = xmlToJson(xml).Body; console.debug(json); var response = {}; for (var outterKey in json) { if (json.hasOwnProperty(outterKey)) { temp = json[outterKey]; for (var innerKey in temp) { if (temp.hasOwnProperty(innerKey)) { response[innerKey] = temp[innerKey].text; } } } } console.debug(response); return response; } // Changes XML to JSON function xmlToJson(xml) { // Create the return object var obj = {}; if (xml.nodeType == 1) {// element // do attributes if (xml.attributes.length &

Categories : Javascript

ASP.NET JSON response without web service
Look into to ASP.Net Web Methods http://msdn.microsoft.com/en-us/library/byxd99hx(v=vs.90).aspx

Categories : Asp Net

Clearing last JSON response
You are adding the table to the window every time you click "return". Change your event listener by removing win.add(view); from it, and replace that line with table.show(); like this: customSearchField.addEventListener("return", function(e) { if(checkInternetConnection()){ nolist.hide(); businessowner.hide(); getdata(); //win.add(view); dont do this!!!! table.show(); ..... }); Then, change this: var table = Ti.UI.createTableView({ backgroundColor: 'transparent', top: '0dp', height:'auto', bottom:'0dp' }); view.add(table); //table.show(); win.add(table); table.hide(); Now you will only have one instance of a table, and you can use setData inside the return listener every time you want to change all the rows.

Categories : Javascript

Save JSON response
As per your callback function signature, you're receiving a variable named response. That is the entire returned object. That object has a property of its own named response. You need to access response.response.session_token (or edit the returned object to return only what's after response: if response.session_token is what you want.

Categories : Javascript

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

alert a json response
Try this: // your json data var s = '{"sEcho":1,"iTotalRecords":1,"iTotalDisplayRecords":1,"aaData":"{null}","errors":{"msisdn":"phone non valide"}}'; // change in json object var obj = JSON.parse(s); // get errors value console.log(obj.errors); Make sure that you have valid json data.

Categories : Javascript

Not able to retrieve JSON response in my JSP
Use "success" (not "Success"). Try this: $.ajax({ type: "GET", url: "AjaxActionController?", dataType: "json", data: "leave_Type="+leave_Type, success: function(data){ alert(data); return_Leave = data.LeaveType; alert(return_Leave); } }); NOTE: If the server sets the Content-Type header value to application/json then jQuery will automatically convert the response to a JavaScript object and you typically don't need to use the dataType property. I would recommend removing async: false so that the request is asynchronous. Synchronous requests are bad practice and you should avoid them. The end-user cannot interact with the page while the synchronous request is being handled by the server and the page will seem to be frozen.

Categories : Javascript



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