w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to Unmarshall JSON Retrived over http in Go
The error data is a []byte slice; you will likely get something more useful if you Printf it to a %s (fmt.Printf("foo: %s ", foo)) or wherever you have it now wrap it in string(foo). I made a simpler example of your Unmarshall, and it seems to work fine. I suspect the problem is with the input data after all? package main import ( "encoding/json" "log" ) type UniqueIDDocID struct { UniqueID int64 `json: "UniqueID"` DocID int64 `json: "DocID"` } type UniqueIDDocIDCollection struct { FullList []UniqueIDDocID } const INPUT = `[{"UniqueID":1234, "DocID":5678}, {"UniqueID":5678, "DocID":9101112}]` func main() { coll := new(UniqueIDDocIDCollection) err := json.Unmarshal([]byte(INPUT), &coll.FullList) if err != nil { log.Printf("Could not un

Categories : Json

Strange $.post() AJAX error when parsing JSON
Use ajax as $.ajax({ url:url, type:'post', dataType:'json', success:callback }) With this type you can set lots of parameter in low level. With datatype attribute jQuery parses JSON and send data as callback function.

Categories : Javascript

AngularJS templates can't use JSON that contains hyphen
try {{item.link['xx-test'].href}} For further reading on bracket notation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects

Categories : Angularjs

Add hyphen symbol in json object creation in javascript
Quote the property names that contain dashes: "student-id" : "123" You may want to use an underscore instead: student_id : "123" Or camel case: studentId : "123" Otherwise, you'll have to access the property with the bracket notation foo['student-id'], which doesn't look as nice as foo.studentId.

Categories : Javascript

Unexpected symbol error in parse(text = str) with hyphen after a digit
You can easily reproduce the parse behavior with : str <- "3a" parse(text = str) parse try to parse your str as a variable name. Or, you should give an available variable name, either it should not begin with a digit or you should put it between ``. the following works : str <- "`3a`" parse(text = str) and in your example , this works also : str <- "abc12-`3def`" parse(text = str) Finanly for your second example , it is logic that it will not work since you don't give an avaible expression to parse: str <- "abc123-" ## this will like myvar- if your - is just a string sperator, why not to transform it to _? for example: parse(text=gsub('-','_',str))

Categories : R

unmarshall without XmlRoot
You need to use one of the unmarshal methods that takes a Class parameter. JAXBElement<Foo> je = unmarshaller.unmarshal(source, Foo.class); Foo foo = je.getValue();

Categories : Java

Marshall a List to XML works - but how to unmarshall?
MyListWrapper If you want MyWrapperForList to unmarshal holding an instance of ObservableList then you will need to setup your class in one of the following ways. Property of Type ObservableList import javax.xml.bind.annotation.XmlAnyElement; import javafx.collections.*; public class MyWrapperForList<T> { private ObservableList<T> list; public MyWrapperForList() { list = FXCollections.<T>observableArrayList(); } public MyWrapperForList(ObservableList<T> list) { this.list = list; } @XmlAnyElement(lax = true) public ObservableList<T> getItems() { return list; } } List Property Initialized to Instance of ObservableList import java.util.List; import javax.xml.bind.annotation.XmlAnyElement; import

Categories : Java

JAXB - Marshall/Unmarshall issues
You can use the JAXB EclipseLink MOXy implementation to access the XmlPath annotation: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "track1", "track2", "track3", "value" }) @XmlRootElement(name = "LoyaltyID") public static class LoyaltyID { @XmlElement(name = "Track1") protected String track1; @XmlElement(name = "Track2") protected String track2; @XmlElement(name = "Track3") protected String track3; @XmlAttribute(name = "entryMethod") protected String entryMethod; @XmlPath("text()") protected String value; /** * Gets the value of the track1 property. * * @return * possible object is * {@link String } * */ public String getTrack1() { return tr

Categories : Java

Parsing this strange JSON using PHP
use json_decode $JsonObj = json_decode($JsonString); if( $JsonObj === NULL ) { echo "Malformed JSON string or Recursion limit reached"; } print $JsonObj[0]->url; if the json file is too big you might hit the recursion limit. The default is 512 in 5.3, 128 in 5.2.3, and 20 in previous versions. you can set the recursion depth as the third argument json_decode($JsonString,false,1024); The second argument is a boolean, true if you want an associative array made, false(default) if instead you want an stdClass object. [EDIT] To go past thumbnail you do $decoded_json->query->results->item->thumbnail[0]->url since thumbnail is an array just access it as such. More than likely you will want to loop over it like foreach($decoded_json->query->results->item-&g

Categories : PHP

how to unmarshall an XML String with Name space to Java Object
Metadata Since only the root element is namespace qualified you just need to set the namespace parameter on the @XmlRootElement annotation. @XmlRootElement(name="ValidateAustralianAddressResponse", namespace="http://api.auspost.com.au/ValidateAustralianAddress:v1") public class ValidateAustralianAddressResponse { } For More Information http://blog.bdoughan.com/2010/08/jaxb-namespaces.html Converting XML to Object You can wrap the XML String in an instance of StringReader and unmarshal that. For More Information http://blog.bdoughan.com/2011/08/jaxb-and-java-io-files-streams-readers.html

Categories : Java

How do i unmarshall a xml-document element into object property?
woah, thanks to W A , i got the solution :) You just have to modify the Element Attributes: Element test = doc.createElement("test"); test.appendChild(doc.createTextNode("foo")); test.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:type", "xs:string"); test.setAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema");

Categories : Java

JAXB Unmarshall same elements with different attributes (lang)
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group. MOXy allows you to map to an element based on the value of an XML attribute using its @XmlPath extension: Java Model (Foo) import javax.xml.bind.annotation.*; import org.eclipse.persistence.oxm.annotations.XmlPath; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Foo { @XmlPath("name[@xml:lang='cs']/text()") private String csName; @XmlPath("name[@xml:lang='en']/text()") private String enName; } Demo import java.io.File; import javax.xml.bind.*; public class Demo { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Foo.class); Unmarshaller unmarshaller = jc.createUnmarshaller();

Categories : Java

Unmarshall single non-root node of a long XML file
You can write your own ItemReader extending StaxEventItemReader (or, better, delegating it), redefine method ItemReader.read() and change the condition to indicate reader is "exhausted" just returning null after first valid node read: when Spring-batch found ItemReader.read() method returning null it will stop processing file. You can use chunk-oriented and avoid full file read.

Categories : Java

How to marshall and unmarshall a Parcelable to a byte array with help of Parcel?
First create a helper class ParcelableUtil.java: public class ParcelableUtil { public static byte[] marshall(Parcelable parceable) { Parcel parcel = Parcel.obtain(); parceable.writeToParcel(parcel, 0); byte[] bytes = parcel.marshall(); parcel.recycle(); return bytes; } public static Parcel unmarshall(byte[] bytes) { Parcel parcel = Parcel.obtain(); parcel.unmarshall(bytes, 0, bytes.length); parcel.setDataPosition(0); // this is extremely important! return parcel; } public static <T> T unmarshall(byte[] bytes, Parcelable.Creator<T> creator) { Parcel parcel = unmarshall(bytes); return creator.createFromParcel(parcel); } } With the help of the util class above,

Categories : Android

Strange behavior in JSON wrapping my objects
This: JSON.stringify({ SecretKey: e.Code, CommentId: e.Id, Direction: direction, VoteType:1}) Can yield: {"Direction":{"Id":1,"Code":"1234-5678-9012","Description":"This is 1 comment."},"VoteType":"1"} If your e.Code and e.Id are not defined (SecretKey and CommentId field are then removed) and if direction object is: {"Id":1,"Code":"1234-5678-9012","Description":"This is 1 comment."}`

Categories : Jquery

Strange response from NSData fetching from JSON
Your JSON contains only dictionaries and dictionaries do not maintain order. In other words, the order of elements when you print a dictionary is entirely implementation specific and may even be random. If order is relevant, you have to use lists (e.g. [1,2,3]) For example, you could use the following JSON { "rows": [ { "values":["on", "on", "on", "on", "on", "on", "on", "on", "on", "on"] , "attr": { "total": 10 , "type": "Gold" } } , { "values":["off", "on", "on", "on", "on", "on", "on", "on", "on", "off"] , "attr": { "total": 10 , "type": "Gold" } } ] } If you don't want to change your JSON and get the values, say of row1 in order you could use the following snippet (not recommended, if order is important,

Categories : Iphone

json encode php showing strange characters
You need a special encoding to have readable json result of arabic character (unicode). You can specify otherwise with JSON_UNESCAPED_UNICODE PHP 5.4 or later. json_encode('yourarabiccharacters', JSON_UNESCAPED_UNICODE);

Categories : PHP

Tomcat servlet acting strange with json object
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json"); PrintWriter out = response.getWriter(); Gson gson = new Gson(); LocationTypes locTypes = new LocationTypes(); String json = gson.toJson(locTypes); response.setContentType("application/json"); out.print(json); out.flush(); } try setting content-type as above

Categories : Json

Strange chars in JSON (obtained after cURL auth)
When you call json_decode in PHP on strings that contain these encodings they will be correctly decoded. http://json.org/ lists ufour-hex-digits as a valid character. There is no issue. $ echo json_decode('"u003Eu003C/au003Eu003C/pu003E u003Cpu003E"'); ></a></p> <p>

Categories : PHP

What is the error denotes in Android(JSON) Error parsing data org.json.JSONException:
It simply means that the String (say, some_string) you have given as input to the new JSONArray(some_string) can not be converted to a JSON Array because the string does not follow the required json array format. An example of a proper JSON Array string is given below [ { "title":"title_1", "name":"name_1" }, { "title":"title_2", "name":"name_2" } ]

Categories : Android

Strange error : "error loading plugin. The specified module could not be found"
Are you sure that your plugin is exporting the correct interface using the Q_INTERFACES() macro? If you get the error you have two possible things to check: 1) loader.instance() returns 0: in that case you have to investigate on the reported error. 2) qobject_cast returns 0: in that case I suppose that the problem is in the missing exported interface. Also, you should consider that both of your execution paths are executing the same code, so maybe you're not getting an error at all... I'm referring to this: if (i == NULL ) // Reports the error QMessageBox::information(0, "this", "error loading plugin." + loader.errorString()); else // Hey!? WTF!? Repots the error anyway!? QMessageBox::information(0, "this", "error loading plugin." + loader.errorString()); 3) I was for

Categories : Qt

MySQL Syntax error? Strange error
You have missed the single quote in $Influence. So change your query like this $query=mysql_query("INSERT INTO General (NodeName,Quadrant,ResearchOpts, Effects,CostOnUpgrade,Influence,ResearchCost) VALUES ('$NodeName','$Quadrant','$ResearchOpts','$Effects','$CostOnUpgrade', '$Influence','$ResearchCost')") or die(mysql_error()); ?>

Categories : PHP

Strange -1.#IND error in VB.net
You can figure out what's going on by trying following: Console.WriteLine(-1 ^ 0.5) It prints -1, but in fact it is the same as sqrt(-1) which does not have a result in Real numbers. That's weird, isn't it? So what's going on here? ^ has higher precedence than -, so -1 ^ 0.5 is actually -(1 ^ 0.5). That's why it prints -1. You can check the precedence list here: Operator Precedence in Visual Basic The same happens with your code. -0.78125 ^ 2.5 is actually interpreted as -(0.78125 ^ 2.5) which is valid, but if you do (-0.78125 + 0) ^ 2.5 (or even (-0.78125) ^ 2.5) it's not valid anymore, because it would require calculating square root from negative value. That's why you're getting NaN (or -1#IND).

Categories : Dotnet

How to unmarshall incoming request payload as method/function arguments based on content type in Python flask or bottle frameworks
There are some caveats in doing so for code readability but a possible solution is as follow. Define the serialization method. If you need to work with different clients I suggest JSON. Create a decorator and put it between your function and the route @route(...) @expandargs def foo(id, bar, baz): ... In the decorator use request.json() (automatically decodes the payload if it's JSON) to expand the args and then you'll call the wrapped function with original args and the new, say, **expandedargs (note the double asterisks to explode the keywords). Problems arise when mixing positional and keyword args.

Categories : Python

Android - NDK strange error
all what i can read out of the error in your code is that mybe one of the included librarys is using wchar_t, but maybe it is supposed to be an int? so basically the main error is that an wchar_t is an unsigned value, but INT_MIN is signed (-) do you use old headers? or is there more code, then you provided?

Categories : Android

Class strange error
What the messages says is that since you have compile errors, Eclipse cannot perform the auto-implement action. The compilation errors are most probably, either in ItemDAO class or IItemDAO interface. Fix them first and then retry the auto-implement action.

Categories : Java

Strange Meteor Error
sounds like a bug in the Mesosphere package, get in contact with the creator and mention the error https://github.com/copleykj/Mesosphere

Categories : Meteor

strange "not defined" error
You need to have an instance of your view model. Change your binding the following way: var x = new viewModelNewCredit(); ko.applyBindings(x); Somewhat approximated demo at http://jsfiddle.net/gE3a7/.

Categories : Javascript

Strange error on building app
This doesn't fit to be an answer though, I write this on request. Anybody facing problems like this or any kind of build error saying Cannot access the file... Try the following. Most of the time this should solve your problem. Try cleaning the solution and rebuild your solution. Deleted bin and obj folders manually and try again. Worst case you may have to restart VS. Problem should go off. Additionally you could migrate to VS2012 which I feel promising(with less issues) when compared to earlier releases. It atmost crashed twice but previous versions do often.

Categories : C#

Very strange routing error in rails 3
So my guess would be: In your template (projects/index), you are using url helpers like url_for or link_to with links to specific projects. The issue is that the projects have nested routing within your spaces resource. That's why you have to provide any url helper with a reference to both, space and project when you want it to generate an url to a project. RoutingError is also thrown in case an url helper doesn't know how to construct an url. This is a long shot, but I hope it helps.

Categories : Ruby On Rails

Strange error: Can't render polygon
I also had the same problem once in iOS6.1. I was zooming out the map based on a coordinate which was (0.00000,0.00000). In my code:- CLLocationCoordinate2D theCoordinate ; theCoordinate.latitude = [[self.dicOfMAP objectForKey:@"latitude"] doubleValue]; theCoordinate.longitude = [[self.dicOfMAP objectForKey:@"longitude"] doubleValue]; self.pointAnnotation.coordinate = theCoordinate; the value of theCoordinate was(0.0,0.0). So check the value of coordinate.

Categories : IOS

Strange JQuery is not defined error
Change your order if files in gantt.php <script language="javascript" type="text/javascript" src="js/jquery.gantt.js"></script> <link rel="stylesheet" type="text/css" href="css/jquery.gantt.css" /> <script language="javascript" type="text/javascript" src="js/jquery.js"></script> to <script language="javascript" type="text/javascript" src="js/jquery.js"></script> <script language="javascript" type="text/javascript" src="js/jquery.gantt.js"></script> <link rel="stylesheet" type="text/css" href="css/jquery.gantt.css" /> you are loding gantt.js before jquery.js

Categories : Jquery

Strange SQL Server Error/Warning
Unfortunately, intellisense in SSMS isn't the greatest. This stored proc must be new and SSMS hasn't "learned" about it yet, even though it clearly exists. If you were to close SSMS and reopen it, you wouldn't have this issue. I have been so frustrated with intellisense in SSMS that I've been tempted to just turn it off. You can also press Ctrl + Shift + R to refresh the local intellisense cache, and that should take care of it.

Categories : SQL

Strange error in AVX loop vectorization
Raising the alignment to 32 makes the symptom go away. I'm not well versed with these intrinsics, but I wouldn't be surprised if 32-byte alignment were required on 64-bit CPUs #include <mm_malloc.h> #include <immintrin.h> int main() { const int sz = 9; float *src = (float *)_mm_malloc(sz*sizeof(float), 32); float *dest = (float *)_mm_malloc(sz*sizeof(float), 32); for(int i=0; i<8; i+=8) { __m256 buffer = _mm256_load_ps(src+i); _mm256_store_ps(dest+i, buffer); } _mm_free(src); _mm_free(dest); }

Categories : C++

Amazon S3: Strange Error -' Sometimes' SignatureDoesNotMatch, sometimes it does
Are you using the Java SDK? Which version? A bug was introduced in version 1.4.4 I think, and has been fixed in the most recent releases. Once I upgraded to the buggy version, I had intermittent signature problems when using SQS, and I've seen a post on AWS Forums of some people reporting the exact same issue with DynamoDB. Now I upgraded to version 1.4.7 and the bug disappeared. Maybe you are seeing the same bug!

Categories : Authentication

strange error message from website
Actually this was from the loadbalancer, they have started blocking the URLs parameter wise, so when ever i make a ajax call to the back end, it blocks URLs according to the parameters loadbalancer is unfamiliar with.

Categories : Jsp

gcc on MacOS: Strange threading error
I found the solution: If I create the pthread with a larger stack it no longer crashes. I must say that the gdb-warning was very unclear and didn't seem to point at running out of stack space at all (a debugger should be able to detect this right?) Anyway, this code solves it: size_t stacksize = 0; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &stacksize); pthread_attr_setstacksize(&attr, max(stacksize, 1024 * (1024 + 512)); pthread_t wxmt; pthread_create(&wxmt, &attr, mainThread, NULL); As it turns out, the default stack size for pthreads on a Mac is only 512 kB (on Linux it's 8 MB!) - this code increases it to 1.5 MB (1 would probably have sufficed, but since the errors that occur are really strange and I want to avoid havin

Categories : C++

An strange error happened with Arraylist
ArrayList<PeopleModel> newList = new ArrayList<PeopleModel>(); newList = smsUtils.getPeopleList(); for(int i=0;i<newList.size();i++){ System.out.println(i); listPeople.add(newList.get(i)); // Here's the infinity problem. } You're iterating from zero to the SIZE of newList. The problem is that at every loop you're ADDING to the newList. So... The size of newList grows up to infinity, and the loop never stops.

Categories : Java

Strange compilation error with inner classes
Since B is not static, it needs some instance of A to be able to exist, thus the error. If B is static, the error goes away. Ah, forget about the nonsense. It is a bug, and it works on ideone in Java7 mode. However, prior to Java 7 it does not work - see this question, and you need to either Change B to static Add a constructor C() { A.this.super(); } And then it will be working. The reason why this happens before Java 7 might be the following which is from JLS: Let C be the class being instantiated, let S be the direct superclass of C, and let i be the instance being created. The implicit super is called on the immediately enclosing instance of i with respect to S. In the earlier JLS, the immediately enclosing instance is defined as Let O be the innermost lexically

Categories : Java

Value parameters to operator= cause strange compilation error
some_class(some_class &x) : n1(x.n1) { } some_class operator= (some_class x) { n1 = x.n1; return *this; } should be some_class(const some_class &x) : n1(x.n1) { } some_class& operator=(const some_class& x) { n1 = x.n1; return *this; } Using your original signatures, you can't copy or assign from const temporary objects as you show in your sample.

Categories : C++



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