w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How do I pretty-print JSON in Delphi?
Use the superobject library, make sure that you use the latest version from the repository file, not the 1.2.4 ZIP. Then you can format your TSuperObject object with .AsJSON(true) (the 'true' does the trick). [ Note that you have no control over the order in which the JSON fields are displayed ] [ And to create your object from the string: var lJSON : ISuperObject; lJSON := SO(string); ]

Categories : Json

Pretty Print JSON with JBuilder
Try parsing the JBuilder output, then using JSON.pretty_generate on that resulting output json_builder = Jbuilder.encode do |json| ... your json.data ... end json_obj = JSON.parse(json_builder) puts JSON.pretty_generate(json_obj)

Categories : Ruby On Rails

JSON pretty print with highlighting
Focusing in more on your question about iframes - it's an issue in itself. It's not possible to do what you want in an iframe if the domain names aren't the same. However there are some workarounds for the same-origin policy that could help you in this situation. Ideally the service you're pulling from supports jsonp so you don't have to deal with iframes and can do what you like with the json response without worrying about the same-origin policy. As mentioned in a previous answer of mine you can use Prettify to apply syntax highlighting, though you can't highlight a specific line (from what I've found so far). For this example I'll be using the GitHub API. For the HTML, you would have: <pre id="jsonCode" class="prettyprint lang-json"></pre> And the JavaScript to f

Categories : Javascript

how do I enable mongodb cli pretty print? - db.col.find().pretty() not working
You can add these lines to your file in $HOME/.mongorc.js in order to enable pretty print. DBQuery.prototype._prettyShell = true Alternatively, you can use this command that prints docs in array format: db.collection.find().toArray() cheers!

Categories : Mongodb

Parsing JSON information in Objective C (multiple levels)
The key is to understand JSON structure: { } - - this means the underlying object is a dictionary. [ ] -- this means the underlyingobject is an array - (void)fetchedData:(NSData *)responseData { NSError* error; NSDictionary *document = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error]; // all titre:video for album_titre:publicite NSArray *albumArray = [document objectForKey:@"album"]; NSDictionary *dict = [albumArray objectAtindex:0]; NSArray *videos = [dict objectForKey:@"album_videos"]; // to fetch Videos inside album_videos // here you will get al the videos inside key titre_video NSMutableArray *titreVideoArray = [[NSMutableArray alloc]init]; for(int i=0; i< videos.count; i++){ NSDictionar

Categories : IOS

How to ng-repeat into html table with multiple levels of json?
Sounds like you'll need a specific directive that wires up children to be recursive, take a look at this example: Recursion in Angular directives What you'd check on is if what you need to repeat is an object and not a value, then add the new element compile it, and start the process over again.

Categories : Json

How to pretty print XML from Smalltalk?
Take a look at the XML packages on squeaksource.com, ss3.gemstone.com and smalltalkhub.com. There's bound to be something suitable for pretty printing. Syntax highlighting is a different story since it depends on the medium you want to print on. What is your goal? You say that you don't want to use a web browser so I can only assume you want syntax highlighting in the Smalltalk environment? If so, you might have to resort to PetitParser and possibly write your own parser (you probably don't want to do that). Maybe you could give us some more details about what you are trying to accomplish?

Categories : Xml

How to pretty print an xml file in Python?
If the pretty_print attribute does not help, you can probably write your own recursive method to do a pretty print. Something on the lines of def pprint(root, indentTabs = 0): print "<%s%s>" % (indentTabs*" ", root.tag) print (indentTabs+1)*" " + root.value for element in root.children(): pprint (element, indentTabs+1) print "</%s%s>" % (indentTabs*" ", root.tag) Though there might be some already available options. The above method would take care of just tags. You might need to add code to take care of xml attributes as well, if they are present in your xml. EDIT: The above will print in the format <tag> text </tag> You can modify it further according to the output you need.

Categories : Python

How to Pretty Print Hive Output
Use set hive.cli.print.header=true; to print column names [1]. As for the spacing, the output is already tab separated so how you process it further is up to you. [1] https://cwiki.apache.org/Hive/configuration-properties.html#ConfigurationProperties-CommandLineInterface

Categories : Mysql

python xml pretty print not working
A simple solution might be to use StringIO: from StringIO import StringIO from lxml import etree parser = etree.XMLParser(remove_blank_text=True) tree = etree.parse(StringIO(templateXml), parser)

Categories : Python

Ruby pretty print strings
What about class Hash def nice_print max_key_length = keys.map(&:length).max each { |key, value| puts "#{key.ljust(max_key_length)} -> #{value}" } end end and you call MAP.nice_print

Categories : Ruby

Pretty print SciPy array
To remove all exponentiation you need to call the formatter argument. Modifying the example in the docs, something like this should do the trick: sp.set_printoptions(formatter={"float": lambda x: '{:.20f}'.format(x)}) This uses string formatting to print a fixed point number(that is the 'f') with 20 decimal places. So 9.71369349e+02 is represented as 971.36934900000005654874. You will need to decide exactly how to handle this number of decimal places.

Categories : Python

How can I pretty print a quoted list in clojure?
Use clojure.pprint/write with clojure.pprint/code-dispatch: (clojure.pprint/write '(do (println "Hello") (println "Goodbye")) :dispatch clojure.pprint/code-dispatch) For that small amount of code you won't get new-lines. But a call like this (clojure.pprint/write '(do (println "Hello") (println "Goodbye") (println "Hey, you left me out!")) :dispatch clojure.pprint/code-dispatch) Returns => (do (println "Hello") (println "Goodbye") (println "Hey, you left me out!")) To catch that as a string wrap the call in (with-out-str ...)

Categories : Clojure

Pretty print by default in Python REPL
Use IPython shell: In [10]: data = {'SHIP_CATEGORY': '', 'SHIP_QUANTITY': 1, 'SHIP_SEPARATELY': 0, 'SHIP_SUPPLEMENT': 0, 'SHIP_SUPPLEMENT_ONCE': 0,} In [11]: data Out[11]: {'SHIP_CATEGORY': '', 'SHIP_QUANTITY': 1, 'SHIP_SEPARATELY': 0, 'SHIP_SUPPLEMENT': 0, 'SHIP_SUPPLEMENT_ONCE': 0} It also has an option --no-pprint in case you want to disable this pretty printing. IPython shell also has features like tab-completion, multi-line paste, run shell commands etc. So, it is quite better than the normal python shell.

Categories : Python

How to pretty print result of wicket validator
I would suggest to use javascript that reformats the user input on the client side. The following jQuery plugin could probably do the job: http://digitalbush.com/projects/masked-input-plugin/#demo Also see: How to have users enter a formatted date in wicket?

Categories : Java

How do I pretty print a hash to a Rails view?
How about: require 'json' hash = JSON['{"a":"1","b":"2","c":"3","asefw":"dfsef"}'] puts JSON.pretty_generate(hash) Which outputs: { "a": "1", "b": "2", "c": "3", "asefw": "dfsef" } JSON.pretty_generate is more of a debugging tool than something I'd rely on when actually generating JSON to be sent to a browser. The "pretty" aspect also means "bloated" and "slower" because of the added whitespace, but it is good for diagnosing and comprehending what is in the structure so it might work well for your needs. One thing to remember is that HTML, when rendered by a browser, has whitespace gobbled up, so whitespace runs disappear. To avoid that you have to wrap the JSON output in a <pre> block to preserve the whitespace and line-breaks. Something like this should work: <

Categories : Ruby On Rails

Winston doesn't pretty-print to console
I figured out the answer (the documentation is incorrect). If you use the constructor, and manually add transports, you can set options, both for winston, and for individual transports. Certain options need to be added to winston directly, while others need to be added to the transport. E.g.: var winston = require('winston'); var logger = new (winston.Logger)({ levels: { trace: 0, input: 1, verbose: 2, prompt: 3, debug: 4, info: 5, data: 6, help: 7, warn: 8, error: 9 }, colors: { trace: 'magenta', input: 'grey', verbose: 'cyan', prompt: 'grey', debug: 'blue', info: 'green', data: 'grey', help: 'cyan', warn: 'yellow', error: 'red' } }); logger.add(winston.transports.Console, { level: 'trace', pret

Categories : Node Js

Minimod Pretty Print - How to customize line breaks?
It works OK for me: var test = new int[][] { new int[] {1,2,3}, new int[] {4,5,6} }; var settings = new PrettyPrintMinimod.Settings(); settings.PreferMultiline(true); Debug.WriteLine(test.PrettyPrint(settings)); It produces output like this: [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] If that's not really what you're after, there's always the nuclear option - write your own formatter: settings.RegisterFormatterFor(typeof(int[][]), o => { var array2d = (int[][])o; return "[ " + string.Join(", ", array2d.Select(array1d => " [" + string.Join(", ", array1d.Select(s => s.ToString())) + "]")) + " ]"; }); Debug.WriteLine(test.PrettyPrint(settings)); Which produces output like this: [ [1, 2, 3], [4, 5, 6] ]

Categories : C#

How does pretty json works?
To simplejson.dumps add separators=[',',': '] parameter return simplejson.dumps(data, cls=json.DjangoJSONEncoder, sort_keys=True, ensure_ascii=False, indent=self.json_indent, separators=[',',': ']) This work fine with standard python json library but for their similarity I think it's same. To avoid wrong response to the page I would recommend you to add content_type='application/json' to page response.

Categories : Python

Pretty printing JSON from Jackson 2.2's ObjectMapper
According to mkyong, the magic incantation is defaultPrintingWriter to pretty print JSON: Newer versions: System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonInstance)); Older versions: System.out.println(mapper.defaultPrettyPrintingWriter().writeValueAsString(jsonInstance)); Seems I jumped the gun a tad quickly. You could try gson, whose constructor supports pretty-printing: Gson gson = new GsonBuilder().setPrettyPrinting().create(); String jsonOutput = gson.toJson(someObject); Hope this helps...

Categories : Java

Load pretty printed JSON from file into python?
For anyone else finding this in the future googling things similar to what I did when I posted this---you may think your error is in the loading, but mine as above was actually in the JSON itself, rather than the loading (as Martijn Pieters pointed out). I was copying the schema from the jsonschema python project---but this, it turned out, was not JSON, but a deceptively similar-looking python dictionary.

Categories : Python

access to different levels of a json file
This is not close to being valid JSON. Use http://jsonlint.com to make sure you have valid inputs before worrying about your code for unpacking the data. You have multiple un-closed arrays (the "[" character starts an array, "]" ends it, and at least one missing comma (before "bookmarks"). It's hard to tell what is wrong with this JSON, because there are enough errors that the intent is not clear. Your code for accessing the contents is mostly fine, except that "SomeDataIdentifierOfBookmarks" isn't a key that is in your JSON—I presume you mean that would be replaced with an actual value. Edit: Your pasted actual JSON is trying to close the "object" object with a square bracket rather than a curly bracket. jsonlint will turn those errors up quickly.

Categories : Objective C

How to define routes with multiple parameters without pretty urls in Laravel
The Symfony Routing components fetch the REQUEST_URI server variable for matching routes, and thus Laravel's Route Facade would not pick up URL parameters. Instead, make use of Input::get() to fetch them. For example, you would start by checking if the class param exists by using Input::has('class'), and then fetching it with Input::get('class'). Once you have all three, or just some of them, you'd start your model/SQL query so that you may return your results to the user.

Categories : PHP

Multiple levels
I dont know if the rest of your concept is sound, but I think the syntax is off for the part you have shown. try: package { public class Level1 extends Main { public var floor1:Array = new Array( [2,1,1,1,1,1,2], [1,1,1,1,1,1,1], [1,1,1,2,1,1,1], [1,1,1,1,1,1,1], [1,1,1,2,1,1,1], [1,1,1,1,1,1,1], [2,1,1,1,1,1,2] ); public function Level1() { Main.levelArray = floor1; } } } EDIT: if the only thing distinct about each level is the a

Categories : Actionscript

Reading XML in C# multiple levels
Parsing with LINQ to XML (return strongly typed anonymous objects): var xdoc = XDocument.Load(path_to_xml_file); var labels = from l in xdoc.Root.Elements() select new { Product = (string)l.Element("product"), Colour = (string)l.Element("colour"), Size = (int)l.Element("size"), Barcode = (string)l.Element("barcode"), Amount = (int)l.Element("amount") }; Usage: foreach(var label in labels) { // use label.Product etc }

Categories : C#

Databinding on multiple levels
You can use the TreeView of WPF. HierarchialDataTemplate will help you here. for a simple exmaple see MSDNenter link description here <HierarchicalDataTemplate DataType = "{x:Type src:League}" ItemsSource = "{Binding Path=Divisions}"> <TextBlock Text="{Binding Path=Name}"/> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType = "{x:Type src:Division}" ItemsSource = "{Binding Path=Teams}"> <TextBlock Text="{Binding Path=Name}"/> </HierarchicalDataTemplate> <DataTemplate DataType="{x:Type src:Team}"> <TextBlock Text="{Binding Path=Name}"/> </DataTemplate> This shows you a 3 level hierarchy. League Division Team The key is to

Categories : C#

Trying to avoid multiple layout levels
I think that is better to use custom CursorAdapter with ViewHolder. private static class MyCursorAdapter extends CursorAdapter { private final Context context; private final LayoutInflater layoutInflater; public MyCursorAdapter(Context context, Cursor c, boolean autoRequery) { super(context, c, autoRequery); this.context = context; this.layoutInflater = (LayoutInflater) context.getSystemService(Service.LAYOUT_INFLATER_SERVICE); } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { ViewHolder holder = new ViewHolder(); View v = layoutInflater.inflate(R.layout.my_list_item, parent, false); holder.startFinishTimeView = (TextView) v.findViewById(R.id.startFinishTimeView); holder.con

Categories : Android

Multiple levels of routing in Durandal
If you are using durandal 2.0 you can set up the child router. This will allow you to create a new router under the hello world that you can chain on additional info for for sub views in your view. You can look these up on the docs but make sure you set up that router within the view so when you hit a route like #helloworld/subview you have already activated helloworld

Categories : Javascript

Multiple levels of binding in WPF ItemsControl
Your ItemsControl Item template should change a bit. Instead of setting the ListBox as Content of Expander, set it as Content Template. <Expander ExpandDirection="Down" Width="175" Content="{Binding}"> <Expander.Header> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Path=name}" Margin="0,0,5,0" /> </StackPanel> </Expander.Header> <Expander.ContentTemplate> <DataTemplate> <ListBox x:Name="SubListBox" ItemsSource="{Binding Path=enrichments}"> <ListBox.ItemTemplate> <DataTemplate> &l

Categories : Wpf

Abstract Class with Multiple Levels
obj must be declared as Last *, or at least Inter * Inter *obj = new Last; or Last *obj = new Last; If obj is just a CI *, the compiler can't see the parseData() method (your object is instantiated as Last, but immediately implicitly converted to CI and looses the benefit of the method). I suggest that you look for what the notion of upcast means. (See also about implicit conversion here or else)...

Categories : C++

Multiple levels of UserControls using UpdatePanels
You've not provided the code for tabs.ascx, but I would guess you've not defined which controls should trigger postbacks in the update panel. That means all postbacks from controls within the UpdatePanel in tabs.ascx are causing the panel to update, including postbacks from child UserControls. If you use: <asp:UpdatePanel id="upanelInfo" runat="server" ... > <ContentTemplate> ... </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="buttonXXX" EventName="Click" /> .... </Triggers> </asp:UpdatePanel>

Categories : Asp Net

R: Split dataframe by levels of a factor and name dataframes by those levels
sapply( levels( df$Z ), function( x ) list( subset( df, Z == x ) ) ) This will return a list with elements named after the levels of df$Z, each one containing the subset of df. Ops, a better answer was provided, but has been deleted -- I will put the solution here: split(df, df$Z)

Categories : R

Is there a way to get the Pyramid json renderer to output formatted, pretty printed, output?
I just figured it out myself. In my init I added from pyramid.renderers import JSON # ... config.add_renderer('prettyjson', JSON(indent=4)) and then I just do this in my view @view_config(request_method='POST', renderer='prettyjson')

Categories : Python

Node.js EventEmitter and multiple levels of inheritance
In your example both homeController and baseController have the same prototype (which you can verify using getPrototypeOf. .prototype is an attributes of functions. If you want to set the prototype of an object to another object directly without using a function and setting its prototype you can use Object.create Here is what I'd do in your case by the way (using less prototypical inheritance and more structural subtyping). function Controller(){ var obj = new events.EventEmitter(); // Add stuff to controller here obj.on("request",function(){ console.log('Calling request event on baseController'); }); return obj; } function HomeController(){ var obj = new Controller(); obj.on('request', function() { console.log('Calling request event on h

Categories : Javascript

How do you add multiple levels to a single transport in Winston?
Specifying the info level does include all levels that are more severe (eg: warn, error, debug). Likewise, specifying warn includes the warn level, plus the more severe error level.

Categories : Node Js

Selecting the first tag of a certain type in multiple levels of other tags
What you're trying to do is impossible with CSS3 selectors. first-of-type and first-child etc. are relative to their direct parent.

Categories : HTML

Can i have multiple levels of accordians in html page
try this JsFiddle: http://jsfiddle.net/ZGTJb/ CSS .head { background: #eee; cursor: pointer; } .section .head, .section .section { margin-left: 20px; } .section{ display:none; } script <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script> $(document).ready(function () { $('#accordion .head').click(function () { var head = $(this); // remove any active head head.siblings('.head').removeClass('active'); var section = head.next('.section'); //remove .section to exclude from hide all section.removeClass('section'); //hide

Categories : Javascript

Multiple levels of keys and values in Python
The value assigned to a key in a dictionary can itself be another dictionary creatures = dict() creatures['birds'] = dict() creatures['birds']['eagle'] = dict() creatures['birds']['eagle']['female'] = 0 creatures['birds']['eagle']['female'] += 1 You need to explicitly create each dictionary, though. Unlike Perl, Python does not automatically create a dictionary when you attempt to treat the value of an unassigned key as such. Unless, of course, you use a defaultdict: from collections import defaultdict creatures = defaultdict( lambda: defaultdict(lambda: defaultdict( int ))) creatures['birds']['eagle']['female'] += 1 For arbitrary levels of nesting, you can use this recursive definition dd = defaultdict( lambda: dd ) creatures = dd() creatures['birds']['eagle']['female'] = 0 In t

Categories : Python

How to extract a value from xpath when there are multiple namespaces defined at different levels?
Probably there is some cleaner way how to do it (I hope someone else knows) but following could also make a job: //ns1:tag1/node()[local-name() = 'tag2' and namespace-uri() = 'http://samples.com']/node()[local-name() = 'tag3' and namespace-uri() = 'http://samples.edu']

Categories : Xml

Extracting multiple levels of xml data using xpath in postgres
I think you are going to have to do it in multiple stages. Here is as far as I got. You could then extract the elements here and tie them back to the parent: with x as (select '<catalog catalog-id="manufacturer-catalog-id"> <category-assignment category-id="category1" product-id="product1"/> <category-assignment category-id="category1" product-id="product2"/> <category-assignment category-id="category2" product-id="product3"/> </catalog>'::xml as t ), segs_raw as (select unnest(xpath('/catalog', t)) catalog_xml from x), segs as (select catalog_xml, unnest(xpath('/catalog/@catalog-id', catalog_xml)) catalog_id from segs_raw) select * from segs; To coordinate things I think the next step is to pull the category assignment XML out along with the

Categories : Xml



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