w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Could not locate Razor Host Factory type: umbraco.MacroEngines.RazorUmbracoFactory, umbraco.MacroEngines
If you are trying to host the blogengine site within a virtual directory of the Umbraco site, then you will have to amend the blogengine web.config to "remove" all the Umbraco-specific handlers and modules, as these will be inherited by the blogengine application, causing this exception because the application can't find the relevant DLLs in its bin folder. I recently had a similar problem and I have posted the web.config I used in the virtual directory below. Mine was a very simple web application, so obviously this will not work by itself in your blogengine app. You will need to add the relevant parts into your web.config file. Also, this was for a v6 Umbraco install in IIS7.5, so you may have to experiment a little. <?xml version="1.0"?> <configuration> <configSecti

Categories : Iis

Select "umbraco item" using razor
You cannot use server tags inside your razor template. tags like: <umbraco:Item field="field_1" runat="server" /> But you can call @Model.field_1 Final version should look like that: @if (condition) { @Model.field_1 } else { @Model.field_2 } Check this post about razor macros in umbraco: http://www.diplo.co.uk/blog/2011/6/17/using-razor-in-umbraco-47.aspx

Categories : Asp Net Mvc

Getting parameter from macro in umbraco 6 via razor
You have to set the parameter in the macro within the backoffice too, with an alias of "myOwnParameter". See here for the documentation: http://our.umbraco.org/documentation/reference/Templating/Macros/Razor/using-macro-parameters Also, I recommend using camel case wherever you reference the alias, as I seem to remember that when accessing the parameter through the dynamic @Parameter collection, this is how the alias is defined.

Categories : HTML

OrderBy multiple properties in Razor and Umbraco 4.11.8
If memory serves you should be able to chain the OrderBys foreach(var item in Model.AncestorOrSelf("Master").Items.First().PublicationFolder.First().Children.Where("Visible").OrderBy("publicationType").OrderByDescending("date"))

Categories : Linq

In Umbraco 6.1.1 MVC 4, how can I do a form post back to a surface controller using a model that inherits from Umbraco's RenderModel?
Ok, I've had no responses to this question but am now in a position to answer it myself. Maybe it was a fundamental oversight, but not that obvious imho, and information on the Umbraco forum etc about inheriting from RenderModel is fairly limited. Essentially the answer, as was my first instinct, is to solve the original exception "No parameterless constructor defined for this object" by providing a paramaterless constructor. The difficulty is working out what to put inside the parameterless constructor for my model, since it inherits from the Umbraco RenderModel which requires an IPublishedContent instance passed to it's constructor. Luckily while browsing around I happened across this post on the Umbraco forum: http://our.umbraco.org/forum/developers/api-questions/40754-Getting-Curre

Categories : Asp Net Mvc

Umbraco MVC Implementation - View does not depend on Umbraco implementations
No you can't. Simply because all requests pass through a single action. In order to retrieve a path to a CMS-managed page, you need to use the node/content traversal the @Model provides. See here for more details on this. Edit To clarify, the author of the article is suggesting that the Umbraco implementation should be more in line with a traditional MVC implementation with little or no logic in the views. Therefore, any querying of node data should happen prior to the view (e.g. in the Mappers). So this is where you would have to retrieve the links. Umbraco's default MVC implementation forces all requests to go via a single action on a single controller. The author's implementation allows the requests to be shared across one controller per document type - which is better IMO. But it st

Categories : Asp Net Mvc

Umbraco - error when using umbraco.library:NiceUrl(...)
Ok I found a solution: I added an extra check to this part: <!-- Return the url --> <xsl:if test="$i = $max"> <xsl:if test="$id != '' "> <xsl:value-of select="umbraco.library:NiceUrl($id)" /> </xsl:if> </xsl:if> this fixed my problem.

Categories : Xslt

Umbraco MediaService / Umbraco MediaItem not saving
To Save media, I found this method with MediaService. However, I think it's possible another method more refined [HttpPost] public JsonResult Upload(HttpPostedFileBase file) { IMedia mimage; // Create the media item mimage = _mediaService.CreateMedia(file.FileName, <parentId>, Constants.Conventions.MediaTypes.Image); mimage.SetValue(Constants.Conventions.Media.File, file); _mediaService.Save(mimage); return Json(new { success = true}); }

Categories : C#

Consuming JSON Web Services In Razor Web Pages
You are looking for the value in the wrong place. temp_f is not part of the outer object; it is part of the current_observation object. Change this line: <h3>@search.temp_f</h3> to this: <h3>@search.current_observation.temp_f</h3>

Categories : Json

JSON.parse for parsing a json list to javascript array doesn't work
You don't have to parse it, because jQuery does it for you and passed it to your callback function in the data argument. $.getJSON() does not return the JSON. So: $(document).ready(function () { var idContact = @ViewData["IdPhysique"]; var Url = "/Accueil/DonneListeFonctionContact"; $.getJSON(Url, { IdContact: idContact }, function (data) { // here data is an array because jQuery already parsed the JSON // data.length is what you need to test }); }); EDIT: Also the "JSON" response that you show in your question is not valid JSON. Property names must be double-quoted, and so must string values, so it should be: [{"IdFonction":734, "LibellFonction":"Clercs"}, ...

Categories : Javascript

jQuery/JSON Error "SyntaxError: JSON.parse: unexpected character"
According to the docs, the following property: dataType: "json" ... tells jQuery the type of data you're expecting back from the server. Then your action is returning HTML. So when jQuery tries parsing the JSON it's expecting, it runs into HTML, and gives you this error. Either change the action to return a JsonResult, or set your dataType to "html".

Categories : Jquery

How do I use play framework 2's json path to parse json that has been poorly converted from xml?
So, the solution I've come up with is no good for performance intensive code, however it presents a clean interface for mapping. object ThingReads { def reads(source:JsValue) = { val names:Seq[String] = (source "attributes" \ "name").map(_.as[String]) val values:Seq[JsValue] = source "attributes" \ "values" val read = reads[TheThing] = ( ( __ "first")(0).as[String] and ( __ "second").as[List[String]] )(TheThing.apply _) JsObject(names.zip(values)).as[TheThing](read) } } The major negatives being that you're required to iterate the json tree twice two build the "nicer form" json, then again when you extract your values. Also if your key-value pair collection (attributes in this case) has a lot of irrelevant data in it, you're paying the price fo

Categories : Xml

how to parse a specific json string that does not work with traditional json parsers
I can give it to you in C#... but converting in VB.NET should be easy. JObject obj = JObject.Parse(json); // json == your json JObject error = obj["error"] as JObject; if (error != null) { JValue message = error["message"] as JValue; if (message != null) { // found } } In VB.NET should be: Dim jobj As JObject = JObject.Parse(json) ' json is your json Dim jerror As JObject = TryCast(jobj("error"), JObject) If jerror IsNot Nothing Then Dim jmessage As JValue = TryCast(jerror("message"), JValue) If jmessage IsNot Nothing Then Dim message As String = jmessage.Value(Of String)() Dim lines As String() = message.Replace(vbCrLf, vbCr & vbCr).Split(New String()() = { vbLf }, StringSplitOptions.None).[Select](Function(p As String) p.Repla

Categories : Dotnet

Python json dump not read by javascript JSON.parse
You're not closing the file, which will likely result in an incomplete file when you're trying to read that again. How about with open(filename, "w") as outfile: json.dump(myobject, outfile)

Categories : Javascript

How to parse json array without json object title in android?
This is a JSONArray and not a JSONObject - to make a JSONObject from it, use JSONObject jsonObject = jsonArray.getJSONObject(0); this gets the first JSONObject from this JSONArray. If you have multiple JSONObjects, use this: JSONObject jsonObject; for(int n = 0; n < jsonArray.length(); n++) { jsonObject = jsonArray.getJSONObject(n); } To get the values: jsonObject.getString("name");

Categories : Android

jquery json needing to parse json from data element before using it
From the jQuery documentation: When the data attribute is an object (starts with '{') or array (starts with '[') then jQuery.parseJSON is used to parse the string; it must follow valid JSON syntax including quoted property names. If the value isn't parseable as a JavaScript value, it is left as a string. http://api.jquery.com/data/#data2 So it seems your second JSON data is very likely invalid.

Categories : Jquery

What's the difference between JSON.load and JSON.parse methods of Ruby lib?
JSON#parse parses a JSON string into a Ruby Hash. JSON.parse('{"name": "Some Name"}') # => {"name" => "Some Name"} JSON#load takes either a string or IO (file etc) and converts that to Ruby Hash/Array JSON.load File.new("names.json") # => Reads the JSON inside the file and results in a Ruby Object. JSON.load '{"name": "Some Name"}' # Works just like #parse In fact, it converts any object that responds to a #read method. For example: class A def initialize @a = '{"name": "Some Name"}' end def read @a end end JSON.load(A.new) # => {"name" => "Some Name"}

Categories : Ruby

How to parse the JSON Date format from the below given json data using jquery?
The object returned is an associative array so you can access the property as follows: $.getJSON("json_data.json",function(jd){ var dates = jd["2013/02/05"][0].colour; alert(dates); }); JS Fiddle: http://jsfiddle.net/DLKfK/ On a side note, that is a pretty nasty object. I'm not sure why it needs to assign an array to the date property. If you have control over the object I would refactor it. One thing you should definitely refactor is the extra common after the array since this make the JSON invalid. { "2013/02/05": [ { "id": "84eb13cfed01764d9c401219faa56d53", "colour": "#000000", "category": "custom" } ], //this comma is invalid }

Categories : Jquery

Why does this simple JSON object throw an error with JSON.parse?
JSON.parse expects a string. The value of t is a javascript object, so it doesn't need to be parsed. If you had: var t = "{"message":"ok, Heru we go!"}"; then JSON.parse would be what you were after.

Categories : Javascript

How to render MS date time JSON format in Razor files
JSON does not define a date format. However, the date format used by your client side component is most likely the number of milliseconds elapsed since 01 January 1970 00:00:00. To produce the expected output you need to compute the number of milliseconds elapsed and you can do it like this (assuming dateTime contains the date you want to convert): var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var elapsedSinceEpoch = dateTime - epoch; var formattedDateTime = string.Format( @"""/Date({0:F0})/""", elapsedSinceEpoch.TotalMilliseconds ); To use this formatting in a Razor view it is probably best to wrap the code in a helper method.

Categories : C#

Razor syntax error serializing ASP.NET Model to JSON with Html.Raw
Using function Implement a simple JavaScript set function that returns input argument: function set(value){ return value; } Use this function to assign Razor model value to a JavaScript variable: var data = set(@Json.Encode(Model)); As an option you can use anonymous function: var data = function() { return set(@Json.Encode(Model)); }();

Categories : C#

Javascript JSON.Parse method fails on clean json data - syntax error unexpected token
your file does not contain valid JSON. JSON keys must be quoted, and string values must use double quotes. Just because it might execute as a valid JavaScript object, does not mean that it is valid JSON (the data interchange format). [ { "AollName": "YUI678", "Contract": "123-33" }, { "TollName": "YUI678", "Contract": "123-33" } ] would be valid.

Categories : Javascript

Parse recursively unknown JSON structure with JSON.NET
I know this question is explicitly about JSON.NET but in the hopes that you don't know about the awesome ServiceStack library, I'd like to add a recommendation that you move to that instead. Specifically, the ServiceStack.Text namespace has a JSON Serializer that's much faster than JSON.NET's serializer. In addition, they have a JSONObject.Parse method that handles your use case better (I believe). See this stack overflow post which pretty much matches what you are looking for: ServiceStack.Text.JsonObject.Parse vs. NewtonSoft.Json.Linq.JObject.Parse for nested tree of 'dynamic' instances?

Categories : C#

How to parse a simple JSON string to a DataSet with Json.Net
Instead of deserializing to a DataSet, have you considered creating a custom class for your data and deserializing to that instead? It might be a little more straightforward to work with. For example, if you define a class like this: class Data { [JsonProperty(PropertyName="w_vendor")] public List<string> Values { get; set; } } Then you can deserialize like this: string json = @"{""w_vendor"":[""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914115361"",""914

Categories : Json

Bing Maps JSON not parsing with JSON.parse
As others have mentioned, it did parse, you just don't recognise the result. JSON is a serialisation of an object heirarchy to a string. JSON.parse(...) turns a JSON serialisation (string) back into an object heirarchy. That heirrarchy of objects can't juse be displayed -- it can be traversed! -- you'll need to encode it into something that can be displayed (for example HTML). To do that, you traverse the object heirarchy building up an HTML fragment string. Then you can simply add that to the HTML DOM via the innerHTML propery of an existing element (say a container DIV).

Categories : Javascript

JSON.stringify and JSON.parse wont work in IE9
You can try adding <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5.01 Transitional//EN"> or <!DOCTYPE html> Also check this.

Categories : Javascript

changing d3.JSON in Hierarchical Bars to JSON.parse
You're probably going to have to read a little more documentation before having a working understanding of what's going in this function. This is a tricky example to start with; I'm just going to walk you through what my process of trying to understand would look like. Going line by line: d3.json("readme.json", function(root) { This loads the referenced json file and calls function with it. 'root' starts out equal to the json file. hierarchy.nodes(root); Looking through the code, we find where hierarchy is declared: var hierarchy = d3.layout.partition() .value(function(d) { return d.size; }); So hierarchy is some kind of layout and hierarchy.nodes will add some useful attributes to root that will make it easier to graph. x.domain([0, root.value]).nice(); searching for

Categories : D3 Js

Can JSON.parse() indicate a valid JSON format?
The grammar given in ECMA-262 15.12.1.2 - The JSON Syntactic Grammar states: JSONText : JSONValue JSONValue : JSONNullLiteral JSONBooleanLiteral JSONObject JSONArray JSONString JSONNumber Therefore plain primitive type values are actually valid JSON. Your expectation that only arrays and complex objects are valid JSON is wrong. JSON.parse(1) will be coerced to a string, so it is equivalent to JSON.parse("1"). And 1 is a valid JSONValue and therefore a valid JSONText resulting in the the parser just returning 1 again. Same with JSON.parse("123"). The ECMA-262 grammar seems to differ from the one given in RFC 4627, but expect browsers to follow ECMA rather than the RFC. PS: You may still validate further with something like: var v = JSON.parse(jsonString); if (v !== new

Categories : Javascript

parse JSON array with json.NET and C#
This is because your routeDirections is specifically asking for the first element in the array: JArray routeDirections = (JArray)routeData["routes"][0]["directions"]; You need to move this logic inside the loop and use the current loop indexer: for (int i = 0; i < routeIdArray.Count; i++) { Route BusRoutes = new Route(); JObject routeIDarrayObject = (JObject)routeIdArray[i]; BusRoutes.routeID = (string)routeIDarrayObject["routeID"]; JArray routeDirections = routeIDarrayObject["directions"];

Categories : C#

How can I parse json in iOS
Try: NSString * FRid = [[json objectAtIndex:i] objectForKey:@"ViewId"]; NSArray * FRName = [[json objectAtIndex:i] objectForKey:@"Label"]; *Label Key contains an array, not a string. And after this you can convert the array to string by following, NSString *FRNameString = [FRName componentsJoinedByString:@", "];

Categories : IOS

How to parse JSON?
You can associate differently-named JSON and C# properties by decorating your C# properties with JsonProperty attributes specifying the name used in the JSON. If you have an object that contains dynamic property names, you need to use a Dictionary<string,X> to receive the deserialized values, where X is either object or a class you defined (I would recommend the latter wherever possible). With these points in mind, you can define your classes like this: public class Response { [JsonProperty(PropertyName = "success")] public String Success { get; set; } [JsonProperty(PropertyName = "resource")] public String Resource { get; set; } [JsonProperty(PropertyName = "count")] public Int32 Count { get; set; } [JsonProperty(PropertyName="last-modified")]

Categories : Json

JSON Parse in C#
The "inner" city in your json object is adding a nested object within the array. Try this json code : { "cities": [ { "id": 1, "name": "A.S.Peta", "status": "Active" }, { "id": 2, "name": "Strasbourg", "status": "Active" } ] } If you need to stick to your originial json structure, you can try this c# code: public class City2 { public int id { get; set; } public string name { get; set; } public string status { get; set; } } public class City { public City2 city { get; set; } } public class RootObject { public List<City> cities { get; set; } } This code has been automatically generated by this very useful web tool: json2C#

Categories : C#

How to parse JSON-C in .net
Can you try the below code. I have saved the json data as text file. Using jsonCsharp you can generate the model class. http://json2csharp.com/ var json = System.IO.File.ReadAllText(@"C:json.txt"); //get json data var result = JsonConvert.DeserializeObject<RootObject>(json); public class PageInfo { public int totalResults { get; set; } public int resultsPerPage { get; set; } } public class Id { public string kind { get; set; } public string channelId { get; set; } public string videoId { get; set; } } public class Default { public string url { get; set; } } public class Medium { public string url { get; set; } } public class High { public string url { get; set; } } public class Thumbnails { public Default @default { get; set; } public Me

Categories : C#

How to parse this json?
Use either Jackson or Gson for this. They will allow you to supply a POJO to return as. This makes it a whole lot easier than defining JSonArray's. Additionally assuming you are making a web request, I recommend using RoboSpice and Spring for Android for a more robust experience. Links: http://wiki.fasterxml.com/JacksonDownload https://code.google.com/p/google-gson/ https://github.com/octo-online/robospice

Categories : Android

Trying to parse JSON from a url using C#
System.Runtime.Serialization.Json really isn't all that bad. Yes, it is the library you should use if you don't want to go third-party. The exception to this is if your JSON is trivial. If it's trivial, just do the string parsing yourself.

Categories : C#

Why JSON.parse('[123]') returns 123?
It is an array of a single integer; it's just that a quirk of JavaScript makes the string representation of an array be the string representations of the elements joined by commas, without the [ and ]. You know it's an array because result instanceof Array JSON.stringify(result) === '[123]'

Categories : Javascript

How to parse Date from JSON
Try this: function ParseDateToLocale(jsonDate) { var date = new Date(parseInt(jsonDate.substr(6))); var myDate = new Date(date); var formatted = myDate.toLocaleString(); return formatted; } See it working here: http://jsfiddle.net/2ft3A/.

Categories : Javascript

parse through json correctly
With this code, your properties are overwritten: var obj = { "kamera": "EOS 5D", "link": "/unterwassergehaeuse-fuer/canon-eos-5d/", "kamera": "EOS 5D Mark II", "link": "/unterwassergehaeuse-fuer/canon-eos-5d/", "kamera": "EOS 5D Mark III", "link": "/unterwassergehaeuse-fuer/canon-eos-5d/" } is equivalent to: var obj = { "kamera": "EOS 5D Mark III", "link": "/unterwassergehaeuse-fuer/canon-eos-5d/"} That's the reason why you get only the last string. You cannot define an object with multiple properties with the same name

Categories : Jquery

JSON.parse vs json_decode
The language! There is no function called JSON.parse (PHP does not have this syntax at all). This is Javascript. json_decode() is PHP and parses JSON to PHP Objects, arrays, etc. http://php.net/manual/function.json-decode.php

Categories : PHP

How to parse The following JSON in Javascript?
tried this and worked var s = '{ "status_code": 200, "status_txt": "OK", "data": { "expand": [ { "short_url": "http://bit.ly/msapps", "long_url": "http://www.microsoft.com/web/gallery/?wt.mc_id=soc-in-wag-msp-M389", "user_hash": "gbL9jV", "global_hash": "eHgpGh" } ] } } ' var d = JSON.parse(s); console.log(d.data.expand[0].short_url); console.log(d.data.expand[0].long_url);

Categories : Javascript



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