w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Post nested Json to spring controller
Try to modify MyAuthentication like this public static class MyAuthentication extends AuthenticationInfo { @JsonProperty("AuthenticationInfo") private AuthenticationInfo AuthenticationInfo; public IndexController.AuthenticationInfo getAuthenticationInfo() { return AuthenticationInfo; } public void setAuthenticationInfo(IndexController.AuthenticationInfo authenticationInfo) { AuthenticationInfo = authenticationInfo; } @Override public String toString() { return "AuthenticationInfo : " + AuthenticationInfo; } } Jackson's default jsoin properties start with a lowercase letter.

Categories : Java

json return null value after POST
When you set the contentType in the ajax, you are setting the contentType for the request not the response. It fails with the JSON contentType because the data you're sending is key/value formatted data (which is missing the encoding) and so the data doesn't match the contentType. The JSON contentType header is for when you're sending raw JSON with no identifiers, but in your case you have an identifier hist_json=. I suggest changing to: data: { hist_json : JSON.stringify(json_hist) }, Using an object with the hits_json key will mean that jQuery will safely URL encode the JSON and will allow the PHP to pick it up with $_POST['hits_json']. If you want to use the JSON contentType then you will have to change the ajax to: data: { JSON.stringify(json_hist) }, // <-- no identifier

Categories : PHP

Nested JSON array returning null In WinRT
I would do it bit differently. First add json.net from NuGet Then add these two classes to your project: public class Course { public int CourseId { get; set; } public string Name { get; set; } } public class Student { public Course Course { get; set; } public int ID { get; set; } public string Name { get; set; } public int Age { get; set; } public string Sex { get; set; } public bool HasScholarship { get; set; } } Now the parsing looks like this HttpClient client = new HttpClient(); HttpResponseMessage response = await client.GetAsync(new Uri("http://localhost:17775/api/Students")); var json = await response.Content.ReadAsStringAsync(); var Students = JsonConvert.DeserializeObject<ObservableCollection<Student>>(json);

Categories : C#

Jersey client: How do I POST nested JSON data?
Form is essentially a Map that limits your values to Strings. What you need is a simple Map (e.g. a HashMap). Every nested element will also be a map. So you will have something like this. Map<String, Object> data = new HashMap<String, Object>(); data.put("customer", "Someone"); data.put("date", "2013-09-12"); Map<String, Object> item1 = new HashMap<String, Object>(); item1.put("sequenceNo", 2); item1.put("name", "foo"); data.put("items", Arrays.asList(item1)); This way you can do as much nesting as you need. Alternatively you can create a few classes that represent your data structures. Jersey will know how to serialize it. class Item { String name; int sequenceNo; // getters & setters } class Data { String customer; String date; List<Ite

Categories : Java

Why is IE6 sending me NULL characters (0x00) as JSON POST data?
Thanks Eric, you were right! When AJAX post requests were cancelled in Internet Explorer, it still sent them to the server, but with no actual content and with an incorrect content length in the header. We read the content using: request.InputStream.Position = 0; byte[] content = new byte[request.ContentLength]; request.InputStream.Read(content, 0, request.ContentLength); it created a byte array of 's because there was no content to overwrite the initialized array.

Categories : Json

How to solve null values being transformed (or not) for JSON post by the modelbinder
Try using a custom model binder, it may not ultimately be necessary but it will help you debug what is actually happening with the value passed to the server. It is a very easy process and is really just two steps: 1) Create a class that implements the System.Web.Mvc.IModelBinder interface, I believe it is just the one method, BindModel(). 2) Add the binder in the OnApplicationStart() method of the Global.asax.cs like so ModelBinders.Binders.Add(typeof(AdjustmentDefaultsModel), new YourModelBinder());

Categories : Json

Why is json response NULL when I send video file larger than 20MB via POST?
When you receive a response for a POST request, first check the status code. If the POST request succeeded: If status code equals 200 (OK) or 204 (No Content) the response body is likely empty or it describes the result of the operation. With either status codes, the request hasn't created a resource which can be identified by a URI. If status code equals 201 (Created) the request created a resource on the server and the response body may describe the result of the operation, and the response should contain a location header where the new resource can be located. Usually, the web service API describes the details about the response body (if any) and its content type and character encoding. Possibly, there are more than one format that can be send, e.g. JSON or XML. If the POST reques

Categories : IOS

python json.loads / json.load truncates nested json objects?
JSON doesn't care about the keys for objects, but the json.load and json.loads convert to a Python object using this conversion table. JSON objects are turned into python dict's, which means you can't have repeated keys.

Categories : Python

Avoiding nested each loops when handling nested JSON data
JSON is "just" javascript object literals. You can skip the jQuery call, and just reference the objects and arrays directly after you parse it. obj.custom_sql_rule[0].something_else[0]; of course, your JSON is a bit oddly-formed. If at all possible, don't arbitrarily mix objects {} and arrays [] . Use the latter when you have lists of identical objects or primitive data, and the former when you have named properties. And once you have a valid javascript object, you can just iterate through its properties. for(var sqlProp in jsonObj) { if(jsonObj[sqlProp].error) { errorsContainer.append("<div>" + jsonObj[sqlProp].error + "</div>"); } }

Categories : Javascript

nested json with jQuery: create List of nested item
Your problem is that institut is an array containing a single object, so you can reference that single object using institut[0]. This will work: $.each(data.fakultaeten, function (key, value) { var mother = "<li id='first'>" + value.name + "<ul>"; $.each(value.institut[0], function (key1, value1) { alert(key1); }); }); Here is a working example

Categories : Jquery

How to convert php null values to null in JSON string?
do not create your JSON string by hand. PHP has an excellent function http://php.net/manual/en/function.json-encode.php

Categories : PHP

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

Is it possible to create nested JSON objects in haskell using Text.JSON?
Text.JSON allows you to nest objects, as you can see by the type definition: data JSValue = JSNull | JSBool !Bool | JSRational !Rational | JSString JSString | JSArray [JSValue] | JSObject (JSObject JSValue) newtype JSObject e = JSONObject { fromJSObject :: [(String, e)] } The type is recursive - JSValues may be JSObjects which in turn may be dictionaries of JSValues.

Categories : Json

Rails JSON API testing POST request with PARAMS in JSON
I found my answer on a post here(RSpec request test merges hashes in array in POST JSON params), I think what I was doing wrong concerned the arguments to the request. so this worked: it "should return an error if there is no correct email" do params = {:subscription => {:email => "andre"}} post "/magazine_subscriptions", params.to_json, {'ACCEPT' => "application/json", 'CONTENT_TYPE' => 'application/json'} end

Categories : Ruby On Rails

JSON POST Request - JSON data, How to do a post request with data in JSON format
You can use ajax if you script will be on the same server, the server support CORS or the server support JSONP. Using jQuery it will be: var data = {"contactsync":{"rev":4,"contacts":[{"fields":[{"value":{"givenName":"dfgheeej","familyName":"ffftestfff"},"type":"name","flags":[],"op":"add"},{"value":"fffffff","type":"nickname","flags":[],"op":"add"},{"value":"fffff@fffff.com","type":"email","flags":[],"op":"add"}],"categories":[],"op":"add"}]}}; var url = 'site.com/anything/addformat=json&wssid=t4764.444&wssid=some_value&windowid=&r=776566756'; $.post(url, JSON.stringify(data), function(response) { }); if you can't use ajax you will need to create a proxy in php (just pass the json to the remote address and print response) like: function post($url, $data) { $ch =

Categories : PHP

MVC4 controller post multiple json objects to controller, ajax post
Try this $.ajax({ type: "POST", url: "SomeUrl" dataType: "json", contentType: "application/json; charset=utf-8", data: { 'userLogin' : { 'Username' : 'Username', 'Password' : 'Password' }, 'contact' : { 'Firstname' : 'Firstname', 'Lastname' : 'Lastname' } } });

Categories : C#

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

Can I Set Nested Values on MOXy DynamicEntities that are null?
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group. You would need to do something like the following: jaxbContext.setValueByXPath( person, "first/text()", null, "Tres"); jaxbContext.setValueByXPath( person, "last/text()", null, "Bailey"); Object address = jaxbContext.createByXPath(person, "address", null, Object.class); jaxbContext.setValueByXPath(person, "address", null, address); jaxbContext.setValueByXPath( person, "address/city/text()", null, "Cowpens"); jaxbContext.setValueByXPath( person, "address/state/text()", null, "SC"); I can see the behaviour you are looking for in your question. Would you mind entering an enhancement request using the link below: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Eclip

Categories : Java

Why won't this nested Average work when joining on null value?
Change the .Where statement into: Where(av => av.ModelId == v.ModelId || (!av.ModelId.HasValue && !v.ModelId.HasValue)) to get the averages of records without ModelId.

Categories : C#

Why are my headers null after a POST?
You're parameter is of the wrong type. You should declare the parameter as a String. HttpHeaders is for getting all the headers and is annotated with a @Context. @HttpParam can only be converted to a limited number of types. From the Jersey documentation for HeaderParam. Binds the value(s) of a HTTP header to a resource method parameter, resource class field, or resource class bean property. A default value can be specified using the DefaultValue annotation. The type T of the annotated parameter, field or property must either: Be a primitive type Have a constructor that accepts a single String argument Have a static method named valueOf or fromString that accepts a single String argument (see, for example, Integer.valueOf(String)) Be List<T>, Set<T> or SortedSet<T&

Categories : Java

Rails Post comments nested within category
I think you're forgetting categories. You need to either provide a category: Controller def new ... @category = Category.find(params[:category_id]) ... end def create @post = Post.find(params[:post_id]) @comment = @posts.comments.create!(params[:comment]) redirect_to @post end View <%= simple_form_for [@category, @post, Comment.new ], :url => category_post_comments_path, :remote => true do |f| %> <%= f.input :name %> <%= f.input :email %> <%= f.input :comment %> <%= f.button :submit %> <% end %> or remove categories from the routes like so: Routes resources :posts, path: 'article' do resources :comments, :only => [:create] end

Categories : Ruby On Rails

django rest nested relation in post/put
Have you tried creating a SubCategorySerializer and adding this as a field on CategorySerializer? class SubcategorySerializer(serializers.ModelSerializer): class Meta: model = Subcategory class CategorySerializer(serializers.ModelSerializer): subcategories = SubcategorySerializer(many=True) Docs: http://django-rest-framework.org/api-guide/relations.html#nested-relationships

Categories : Django

POST to nested RESTful resources in Django
REST is about resources. There is no best way to do it. I'll give you my Opinion (I run a big API since a long time). For sake of simplicity I'd just create two resources: Question: /api/v1/question/ Answer: /api/v1/answer/ Why? Because it's simple. Now, in order to make it performant and HATEOAS compatible, you could use different alternatives. For example, when you get a question, you could also get a list of answers: GET /api/v1/question/{q_id}/ { 'question': 'Should I use REST or SOAP?' 'created_date': '...', 'user_id': '99', 'answers': [ { 'answer': 'REST, of course!', 'user_id': 23, 'resource_uri': '/api/v1/answers/818/' }, { 'answer': 'Are you nuts? Use SOAP!', 'user_id': 12,

Categories : Django

Entity Framework Check Nested Null Objects
The nested objects are never null. They are IEnumerable. But I think you want the items where the nested collections are not empty: retvalue = retvalue.Where(x => x.DataEntryProcessInfoView.Any( y => y.DataEntryCheckInfos.Any()); where retvalue is the part before AsEnumerable().Select(x => new DataEntryInfoView()....

Categories : Linq

Getting null values in post wcf service
Modify the interface method: [OperationContract(Name = "GetMediaFile")] [Description(ServiceDescConstants.GetMediaFile)] [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/GetMediaFile")] Stream GetMediaFile(Stream input); And also modify it's implementation: public Stream GetMediaFile(Stream input) { StreamReader sr = new StreamReader(input); string s = sr.ReadToEnd(); sr.Dispose(); NameValueCollection qs = HttpUtility.ParseQueryString(s); string type = qs["type"]; string mediaId = qs["mediaId"]; CustomerBL customerBl = new CustomerBL(); return customerBl.getMediaFile(Convert.ToInt32(type), Convert.ToInt32(mediaId)); } In the web.config, use the following configu

Categories : Wcf

submit a list become null in the post + MVC
in your View you are not rendering Days inside form Render hidden fields inside form with name="Days" like foreach(var day in @Model.Days) { <input type="hidden" name="Days" /> } copy the above code and paste it after <div class="editor-field"> @Html.EditorFor(model => model.CNIL) @Html.ValidationMessageFor(model => model.CNIL) </div> Now,when you submit, the Days values will also submitted to the Post method and you will get values in Days List.

Categories : Asp Net Mvc

Null values being passed when I post in php
You've named your inputs incorrectly. In your PHP, you use these to set the variables: $address_one = $_POST['address_one']; $address_two = $_POST['address_two']; $city = $_POST['city']; But the HTML references the address fields by number, and the city input is actually a duplicate of address2. You need to set the input name attributes to match what you're using inside the $_POST variables.

Categories : PHP

ApiController receives null in POST
Apparently after browsing through blogs for hours this is all you need to do / edit in the above example: public string Post(tester test) { string k = ";;"; return k; } add a class public class tester { public string user { get; set; } public bool close { get; set; } } and change the AJAX to var value = {close:true, user: "<%: uuid %>" }; $.ajax({ type: "POST", contentType: "application/json;charset=utf-8", url: "/api/TEST/", data: JSON.stringify(value) }).done(function(msg) { alert("done"+msg); });

Categories : Json

Will_paginate inside POST form with nested attributes
I would suggest to try some javascript solutions for the paginations. Try using datatables. Check out this link: http://datatables.net/examples/api/form.html Hope it helps.

Categories : Ruby On Rails

How to post nested models in EmberJS with WebAPIAdapter from same view
I guess you need to tell the Adapter that your Source model is embedded. This way the Article and the Source model will be treated as one in terms of creating/deleting etc. Try to define it like this: DS.RESTAdapter.map('App.Article', { sources: { embedded: 'always' } }; For the embedded property there are to possible values, load & always: load: with load the child records are embedded when loading, but should be saved as standalone records. In order for this to work, the child records must have a proper id. always: with always the child records are embedded when loading, and are saved embedded in the same record. Hope it helps.

Categories : Asp Net Mvc

Dynamic linq order by on nested property with null properties
static void Main(string[] args) { var data = new List<MyType>() { new MyType() { SomeProperty = new Inner() { NestedProperty = "2" }}, new MyType() { SomeProperty = new Inner() { NestedProperty = "1" }}, new MyType() { SomeProperty = new Inner() { NestedProperty = "3" }}, new MyType(), }.AsQueryable(); var sorted = data.OrderBy(x => GetPropertyValue(x, "SomeProperty.NestedProperty")); foreach (var myType in sorted) { try { Console.WriteLine(myType.SomeProperty.NestedProperty); } catch (Exception e) { Console.WriteLine("Null"); } } } public static object GetPropertyValue(object obj, string propertyName) { try { foreach (var prop in propertyName.Spl

Categories : C#

Why are the nested objects in my parent object null when posting to my MVC 4 Controller?
The objects from model binding can only be hydrated with the values that are posted. Hence if there are no values in your post corresponding to the asscoiated Engine object than none of its properties will be populated. The default model binding will create a new instance of the object or objects it sees in the action method's parameter list. If you would like the model binding to pull an existing object, say from the database, than you will need a custom model binder.

Categories : Asp Net Mvc

Params error in post method,its getting only null value
Try replacing: nameValuePairs.add(new BasicNameValuePair("content", valueIWantToSend)); with: nameValuePairs.add(new BasicNameValuePair("post[content]", valueIWantToSend)); You need to make sure that the data you're submitting with android is the same format as what would be submitted by an HTML form.

Categories : Android

Null parameters doing HTTP POST from Ajax to Web API
OK, I found the problem after some hours researching. I had to pass the data parameter to ajax function using: "=" + canvasdata, without the parameter name: jQuery.ajax({ url: "../api/webinfo", type: "POST", data: "=" + canvasData, success: function (response) { alert(response); }, error: function (response) { alert(response.responseText); } });

Categories : C#

ASP.Net web api post action param always coming null
This maybe due to the Content-Type you are setting to x-www-form-urlecoded, which expects body like name=value&name=value Try to set content type to xml like this and try. content.Headers.Add("Content-Type", "application/xml");

Categories : C#

Telerik DatePicker returns null on post
Are the startValue and endValue variables in your Javascript code of type Date? If that's the case, convert them to string like this: <script type="text/javascript"> function filterChange() { $("#log").ajaxError(function (event, jqxhr, settings, exception) { alert(exception); }); var startValue = $('#filterStart').data('tDatePicker').value().toLocaleString(); var endValue = $('#filterEnd').data('tDatePicker').value().toLocaleString(); //alert('Index: ' + startValue + ',' + endValue); $.get('@Url.Action("DashboardPartial")', { start: startValue, end: endValue }, function (data) { $("#target").html(data); }); } </script> Also, in your form, remove '@' befo

Categories : C#

Object in ViewModel Null on Post MVC3
It seemed that it was a two fold issue, one I was not creating a new CurrentNotification in the view model constructor, and then after I put that in I was over writing my new CurrentNotification that I just created with a hidden one replacing the good object with the null one.

Categories : C#

Nested Post Model Link broken on static_page in Rails
Your routes are perfect. Most likely your @collection has an nil ID, because was not saved yet. You can also try <%= link_to "link" [@collection, design] %>

Categories : Ruby On Rails

jQuery: nested $.ajax not sending post request intermittently
I've finally solved my problem by creating a second form, adding hidden input fields via jquery and then submitting this. Apparently there's a difference in the order at which elements of the code are executed and maybe the ajax request fired prematurely every now and then, but at any rate with the form sbmit it works every time.

Categories : Jquery

POST to WebAPI controller results in null parameters
So as I expected, it was something stupid: contenttype: "application/json; charset=utf-8", should have been contentType: "application/json; charset=utf-8", The "T" in type wasn't capitalized...there goes half a day!

Categories : Jquery



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