w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Issue while converting linq result to JSON in MVC4 using JavaScriptSerializer
Departments= jss.Serialize( db.Departments.Select(d => new{ DepartmentId = d.DepartmentId, DepartmentName = d.DepartmentName }) );

Categories : C#

Newtonsoft JSON double converting JSON string
Your question isn't clear, so I'll make a guess; You want to serialize Foo class as {d:{fooooo}}. Then it is better if you use anonymous types Foo foo = new Foo(); var json = JsonConvert.SerializeObject(new { d = foo }); No need for Data class.

Categories : C#

C++ type converting issue
int * double expression yields double, that's what the first thing prints. Then you convert to int chopping the remaining part (even if it's almost there, sitting at 10500-DBL_EPSILON), and pass that back. The second prints that value. float-int conversions should be made with care, better not at all.

Categories : C++

String Converting Issue
Default charset of your MySQL server is probably not UTF8. Try to execute the following SQL queries before getting data from the database: SET NAMES utf8 and SET CHARACTER SET utf8

Categories : Java

Issue in Converting my Project from D7 to XE4
Delphi 7 uses ANSI strings (single-byte Chars), while versions of Delphi from 2009 and up use Unicode strings (multi-byte Chars). The most straightforward fix for your code is to change from Char to AnsiChar, string to AnsiString, and PChar to PAnsiChar: Type THotelClientDetails = packed record LSize: Integer; ClientName: array[0..25] of AnsiChar; ClientRoomN: Integer; RWithInternet: Boolean; RoomStatus :Integer; //... etc end; StrCopy(pClientDetails.ClientName, PAnsiChar(ClientNameEd.Text)); // and StrCopy(Pointer(Cardinal(pClientDetails) + SizeOf(THotelClientDetails)), PAnsiChar(ClientNameEd.Text)); Procedure TSForm.GetClientDetails(pClientDetails:PHotelClientDetails; Cntx: Pointer); var ClientName: string; begin ClientName := PAnsiChar

Categories : Delphi

Converting svg to json
As I understood, your problem is that Raphael is not working with imported SVG. There is a way to make the SVG into a Raphael object and then you can use it with Raphael library. Chack out this website: http://irunmywebsite.com/raphael/SVGTOHTML_LIVE.php

Categories : Json

Converting XML to JSON using R
You can convert XML to a list using the xmlToList() function from the XML package, and you can convert a list to JSON using the toJSON() function from the RJSONIO package.

Categories : R

json data formatting issue while building json array
you don't need to enclose objects between quotes. Just push them as literals. dgr.push({value:per,label:k}); if you need to cast value or label as float or string, you can use specific typecasting dgr.push({value:parseFloat(per),label:String(k)});

Categories : Javascript

Issue with converting timestamp to seconds
Assuming that your MySQL session and your PHP settings are both sharing the same timezone, you could use something like this to get a suitable time period in English: function toFriendlyTime($seconds) { // Used in the item view, this function returns a 'friendly', rough-idea type time, like "3 hours" or "4 months" $measures = array( 'month'=>30*24*60*60, 'week'=>7*24*60*60, 'day'=>24*60*60, 'hour'=>60*60, 'minute'=>60, 'second'=>1, ); foreach ($measures as $label=>$amount) { if ($seconds >= $amount) { $howMany = floor($seconds / $amount); return $howMany." ".$label.($howMany > 1 ? "s" : ""); } } return "1 second"; }

Categories : PHP

ERROR converting json
UserListByBusinessAreaContextResult is not an Array. It's a JSONObject. tableData is your JSONArray. So you must have : try { JSONObject mainJson22 = new JSONObject(reply); JSONArray jsonResult = mainJson22.getJSONObject("UserListByBusinessAreaContextResult"); JSONArray jsonArray22 = jsonResult.getJSONArray("tableData"); Log.i("mainjson234","" + jsonArray22); for (int i2 = 0; i2 < jsonArray22.length(); i2++) { JSONObject objJson22 = jsonArray22.getJSONObject(i2); ...

Categories : Android

Converting arraylist to JSON
You are getting an array in response where as you are trying to get an object Replace // getting JSON string from URL JSONObject json = jParser.getJSONFromUrl(url); to JSONArray json = jParser.getJSONFromUrl(url); Also public JSONObject getJSONFromUrl(String url) { //This returns a JSONObject Modify this to return JSONArray }

Categories : Android

Converting JSON to class
As explained in the "Jackson in 5 minutes" page, which takes 5 minutes to read: ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally Entry entry = mapper.readValue(new File("entry.json"), Entry.class); EDIT: sorry, I misunderstoof your question. If you want to read a sub-tree of the JSON into a Java object, then read the full JSON as a Tree, then get the sub-tree from the root node, and use ObjectMapper.treeToValue() to transform the sub tree to an Entry Java object. All the steps are described in the page I linked to.

Categories : Java

converting JSON to array
This JSON is invalid here: [{ id: "1234", name: "Carl", age: "17", //this is invalid }, { id: "9876", name: 'Jhon', age: "19" }] This is a valid version: [{ "id": "1234", "name": "Carl", "age": "17" }, { "id": "9876", "name": "Jhon", "age": "19" }] You can validate here: JSONLint

Categories : Javascript

Converting MongoCursor to JSON
Assuming you want implicit conversion (like in flavian's answer), the easiest way to join the elements of your list with commas is: private implicit def buildJsonString(list: List[DBObject]): String = list.mkString(",") Which is basically the answer given in Scala: join a iterable of strings If you want to include the square brackets to properly construct a JSON array you'd just change it to: list.mkString("[", ",", "]") // punctuation madness However if you'd actually like to get to Play JsValue elements as you seem to indicate in the original question, then you could do: list.map { x => Json.parse(x.toString) } Which should produce a List[JsValue] instead of a String. However, if you're just going to convert it back to a string again when sending a response, then it's an u

Categories : Mongodb

In TSQL converting JSON to XML?
This function works for my tasks: http://sqlsunday.com/2013/05/12/converting-json-data-to-xml-using-a-t-sql-function/

Categories : Xml

Converting JSON From AFNetworking
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id json) { self.results = [json valueForKeyPath:@"data"]; NSError *anError = nil; NSArray *parsedElements = [NSJSONSerialization JSONObjectWithData:elementsData options:NSJSONReadingAllowFragments error:&anError]; for (NSDictionary *aModuleDict in parsedElements){ MosData

Categories : IOS

Converting Crystal Reports to SSRS Issue
Based on the information provided, this formula simply concatenates two exclamation marks onto the field {MM.Jobnumber}. The output for this would look something like this !Jobnumbervalue! If you haven't tried already, http://www.crystalmigrater.com/Default.aspx is an extremely useful tool for what you are trying to accomplish.

Categories : Reporting Services

Issue when converting GET request parameters on viewParam
I was able to find the problem after taking a look at the actual code you sent. The issue is not with the converter. It's with the xml namespaces at the top of your project. For instance, in source-view.xml you have xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:f="http://xmlns.jcp.org/jsf/core" But they should be xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"> And target-view.xhtml should be xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> GlassFish seems to change the namespaces for some reason. I didn't try to find out why it behaves like that though so keep that in mind. Anyway, once I changed it, the correct phases we

Categories : JSF

Converting JSON to DynaTree Object
This is simple if you want to create a dynatree from the object you mentioned simply do this var children = [ { title: "my Title", isFolder: "true", key: 1 } ]; $('#tree').dynatree({ children : children });

Categories : Javascript

Converting NSString to NSDictionary / JSON
Use this code where str is your JSON string: NSError *err = nil; NSArray *arr = [NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&err]; // access the dictionaries NSMutableDictionary *dict = arr[0]; for (NSMutableDictionary *dictionary in arr) { // do something using dictionary }

Categories : Objective C

Converting String of Json to JsonObject
For that, you need to parse your flux json, here the code. JsonObject root = (JsonObject)new JsonParser().parse(jsonString); int i=0; JsonObject dataReports //get and print each object of reports while(root.getAsJsonObject().get("reports").getAsJsonArray().size()>i && (dataReports=root.getAsJsonObject().get("reports").getAsJsonArray().get(i).getAsJsonObject())!=null){ System.out.println(dataReports.toString()); i++; }

Categories : Java

Converting html to Json object
Do you want to output a javascript object to a string? Construct the object: var category=new Object(); category.name="Name"; category.description="My lovely description"; category.subcategories=[]; var subCat=new Object(); subCat.catid=1; subCat.catname="My subcat"; category.subcategories.push(subCat); Alternatively, you could construct the object using literals: var category={ name:"Name", description:"My lovely description", subcategories:[ {catid:1,catname:"My subcat"} ] }; Then return the object as string. return JSON.stringify(category); A reference to Javascript objects if you need more help: http://www.w3schools.com/js/js_objects.asp

Categories : HTML

how to validate JSON string before converting to XML in C#
I recommend using some sort of Regex.Replace(). Search the input string for something like: "([a-zA-Z0-9]+) ([a-zA-Z0-9]+)": and then replace something like (mind the missing space): "(1)(2)": The 1st pair of parenthesis contain the first word in a variable name, the 2nd pair of parenthesis means the 2nd word. The : guarantees that this operation will be done in variable names only (not in string data). the JSON variable names are inside a pair of "s. Maybe it's not 100% correct but you can start searching by this. For details check MSDN, and some Regex examples http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.replace.aspx

Categories : C#

Converting plain string to JSON
There is no connection between the Content-Type and the response itself. Java does not make any provision or validation of the data returned. The Content-Type is primary for the client to determine the content type but for the server it is only a string sent to the client. What the client does when the Content-Type and the real content do not match is up to the client. Also there is no serialization done by Java but the returned value is sent plain to the client.

Categories : Java

GSON / JSON converting from innerJsonObject
First of all the JSON "object" you've written is not even valid JSON! If anything, you could create a JSON like this: { "Param_1": { "SubParam_1": { "type": "String", "required": true } } } And that's very easy, you just need to have the correct class model, something like this: public class YourClass { private Param Param_1; } public class Param { private SubParam SubParam_1; } public class SubParam { private String type; private boolean required; } And then you can use the method .toJson(), like this: Gson gson = new Gson(); String jsonString = gson.toJson(yourObject);

Categories : Android

converting json into jsonp for using it as a callback
LIVE DEMO var allZips = []; $.getJSON('http://data.cityofnewyork.us/resource/xm9j-adfx.json', function(data) { for(i=0;i<data.length;i++){ allZips.push( JSON.parse(data[i].zip_code.human_address).zip ); } alert( allZips ); // 10001,10002,10003,10004,10005,10006,10007,...... }); You're fine with objects until the last one which is a string with escapes: "human_address" : "{"address":"","city":"","state":"","zip":"10001"}" that's why you need to first PARSE the data (transform it into JSON) and than retrieve the zip value. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse

Categories : Javascript

Converting nested tables to JSON
There is a library which converts table to json format: https://github.com/lightswitch05/table-to-json i hope it helps.

Categories : Jquery

Converting PHP BBCode REGEX to JavaScript, can someone help pinpoint an issue?
use this pattern instead: /[b](.+?)[/b]/gi the problem was that + quantifier was greedy (default behaviour) and thus .+ captures all that he can (ie : this is bold[/b] and [b] this is too). If you add a question mark the quantifier becomes ungreedy (=lazy) and stop at the first closing bbcode tag. In the php pattern you can see the U modifier at the end which switch all greedy quantifiers to lazy and all lazy quantifiers to greedy. It's the reason why .+ in the php pattern is lazy.(The default behaviour is inverted). You can notice too the s modifier in the php pattern. s stands for single line. That means that the dot can match newlines too. But Javascript doesn't have an equivalent. To have the same with Javascript you must replace the dot by [sS], otherwhise .+ will stop the matc

Categories : PHP

Issue in converting Timespan variable to 12 hour format
Converting a timespan to a date is not possible, a timespan represents x amount of minutes/hours/whatever and you cannot get an exact date from that alone. If you have a date as a starting point, you can add a timespan and that will give you the new date.

Categories : Asp Net

Java: Issue Reading Text file then Converting
Use a labeled break statement in your for loops to simply exit out of the main do while loop when myline becomes null. The way other objects are being instantiated within the loop doesn't leave much room for easy refactoring hence the use of a labeled break makes sense here. outerloop: do { for (int i = 0; i < 4; i++) { if ((myline = readFile.readLine()) == null) break outerloop; // .. } for (int i = 0; i < 2; i++) { if ((myline = readFile.readLine()) == null) break outerloop; // .. } // .. } while (myline != null);

Categories : Java

Android: JSON not converting object properly
Try this code - Map<String,Object> map = new HashMap<String,Object>(){ private static final long serialVersionUID = 1L; { put("EmailAnswer", "Y"); put("IsSendSupervisor", isSendSup); put("IsSendTC", isSendTC); put("ContentType", "MS"); put("ApprovalResponse", ""); put("EmpId", empId); put("IsSendEmployee", isSendEmp); }}; Edit - JSONArray jsonArray = new JsonArray(); for (String session : SessionsList) { JsonObject jsonObject2 = new JSONObject(); jsonObject2.put("SessionCode", session); jsonArray.add(jsonObject2) } JSONObject json = new JSONObject(map); json.put("MyScheduleRecords", jsonArray);

Categories : Android

Converting JSON to Enum type with @RequestBody
The error message explains what is going wrong: there is no definition for Red inside ColorDefinition. The case needs to match; enum values are case-sensitive. The keys in your JSON need to be RED, GREEN, and BLUE. Internally, Spring uses valueOf to get the enum representation of the String. During deserialization, ColorDefinition.valueOf("Red") will throw an IllegalArgumentException because there is no definition for Red in ColorDefinition. This exception is intercepted by Spring, and this is why you see an error message. However, ColorDefinition.valueOf("RED") will return ColorDefinition.RED because there is a definition for RED in ColorDefinition.

Categories : Java

Converting json from a file to a java object
This simple example works like a charm: DTOs public class SampleDTO { private String name; private InnerDTO inner; // getters/setters } public class InnerDTO { private int number; private String str; // getters/setters } Gson BufferedReader br = new BufferedReader(new FileReader("/tmp/test.json")); SampleDTO sample = new Gson().fromJson(br, SampleDTO.class); Jackson InputStream inJson = SampleDTO.class.getResourceAsStream("/test.json"); SampleDTO sample = new ObjectMapper().readValue(inJson, SampleDTO.class); JSON (test.json) { "name" : "Mike", "inner": { "number" : 5, "str" : "Simple!" } }

Categories : Java

Converting Nested Json files to CSV in java
You are not printing the key. This should fix it. for (Entry<String, JsonElement> s : set) { System.out.println(s.getKey()); //Added printJsonRecursive(s.getValue()); } You can take care of s from here. EDIT If you want to print the keys just once for repeating json objects, create a Java bean to hold the data and populate it during your recursion. Once the bean is complete, add a method there to print all the data in the format you want (printing keys only once and so on).

Categories : Java

Achieving same array structure when converting from JSON and XML
i think this could help you :- $xml = '<?xml version="1.0"?>'. '<people>'. '<person>'. '<name>casper</name>'. '<shoesize>41</shoesize>'. '</person>'. '<person>'. '<name>christine</name>'. '<shoesize>37</shoesize>'. '</person>'. '</people>'; $xml = simplexml_load_string($xml); $data = json_encode($xml); echo '<pre>'; $dataarray=(json_decode($data,true)); $requiredarray=$dataarray['person']; print_r($requiredarray); Output :- Array ( [0] => Array ( [name] => casper [shoesize] => 41 ) [1] => Array ( [name] => christine

Categories : PHP

Restful - Converting Hibernate entities to JSON
One simple approach is to include jackson-mapper-asl dependency to your classpath, and declare your Spring MVC handler method like this: @RequestMapping(...) @ResponseBody public A getA(..) { A a = // fetch A object from persistence layer return a; } The existence of @ResponseBody annotation will cause the object be translated into JSON

Categories : Java

Converting JDouble to Double (JSON library)
Looking at the code (https://github.com/json4s/json4s/blob/7c70e9664232ffee4acf24c8969424cd37957736/ast/src/main/scala/org/json4s/JsonAST.scala) shows that you just need to call the JValue.values method. UPDATE: From your comment it seems that it's not so much that you have a JDouble and want to extract its Double value (and similarly extract a Boolean from a JDouble. Instead, you have a JValue and want to extract its value as a Double or Boolean (knowing in advance the expected type). This can be done with extract, as explained in the README that you linked to: (json "status").extract[Double] or: (json "status").extract[Boolean] See also this test file for more examples: https://github.com/json4s/json4s/blob/master/tests/src/test/scala/org/json4s/ExtractionExamplesSpec.scala

Categories : Scala

TypeError: Converting circular structure to JSON
I dont want active sockets to get lost if a restart should happend Sorry, but this is unavoidable given the process model of operating systems. Your process's resources including network sockets, open files, memory, etc, are freed and reclaimed by the OS when the process exits. In order to achieve something like this you would need a separate load balancer or cluster manager to keep the raw sockets alive while one cluster node/worker restarts. You may want to investigate the node.js cluster module, but given you tried to do this by writing sockets to disk, there are some gaps in your understanding of the OS at this level that you may want to study up a bit more before venturing outside of regular application logic.

Categories : Javascript

Converting Json String to data for Windows 8
Look at this. http://jsonclassgenerator.codeplex.com/SourceControl/latest Also see this SO answer: Deserialize JSON into C# dynamic object? There are so many results: search?q=dynamically+create+c%23+class+from+json

Categories : C#

Converting a specific JSON to Java Object
I haven't worked with Gson specifically, but I have worked with JSON / Java conversion in Jersey and JAXB. I would say that the easiest way to translate the JSON text is to map every {..} to a Class and [..] to a List. For example: Class Data { HistoryListClass HistoryList; Relation related; } Class HistoryListClass { List<History> history; } Class History { String comment; String create; int ID; String ttURL; } Class Relation { String book; String ID; } See also: Converting JSON to Java The "HistoryList" element in the JSON code should probably be written "historyList", and just looking at the code given, I suggest you change it to contatain the list of "History" objects directly.

Categories : Java



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