Feature request for support of JSON data (including condensed JSON). May be able to port quickly from YAML.
Here is a valid condensed JSON record that does not appear to parse correctly in Geany 1.23.1 on Ubuntu 14.04:
{"foo": "bar","baz": ["qux","quxx"],"corge": null,"grault":1,"garply": true,"waldo": "false","fred":"undefined","emptyArray": [],"emptyObject": {},"emptyString": ""}
I've followed the wiki here (including the both the YAML lexer and the Javascript lexer):
http://wiki.geany.org/config/json
But this does not appear to parse JSON properly, particularly when condensed--possibly due to slightly different parsing between YAML and JSON.
For the purposes of sample data for testing and comparing, these sites may be useful:
http://jsontoyaml.com/
http://yamltojson.com/
Thanks in advance; and please let me know how I can contribute to this effort!
What do you mean by "does not appear to parse correctly in Geany 1.23.1"?
If I put this snippet in Geany (from Git, latest dev version) and set the filetype to JavaScript it highlight and folds just fine (which is expeced as IIUC JSON is a strict subset of JavaScript grammar).
But no, it doesn't generate a symbol list (nor does it for YAML data BTW). This could be fixed by writing a CTags parser for JSON (and to my basic understanding of the format I believe it should be pretty trivial), but this also means adding a builtin filetype to Geany, so a little more work.
I fixed the wiki page to propose a working filetype file
Thanks for the update here and in the wiki!
Using JavaScript as the filetype doesn't appear to identify the arrays properly. For example, if you go to the jsontoyaml.com site I listed, convert the default JSON example to YAML, and paste the YAML into Geany, Geany correctly identifies an array called 'baz' (which you can hide or expand with the "+" button.
Pasting in the equivalent JSON and selecting javascript doesn't appear to identify 'baz' as an array that can be expanded. Only the outermost '{}' brackets are recognized as containing an array.
Javascript doesn't fold on arrays, only on {} since that is the block
construct in Javascript, but since JSON is Javascript it highlights
properly.
YAML folds on both {} and [] (at least in the example you linked to)
but doesn't highlight since JSON isn't YAML.
Cheers
Lex
On 27 November 2014 at 13:26, arslaan beatboxa@users.sf.net wrote:
Related
Feature Requests:
#745Actually YAML folds on indentation only, so if it did with this example is only because it was indented like YAML requires.
Correct, but what I am asking for is support for JSON specifically, not Javascript in general (which already appears to work fine). So a JSON file should fold appropriately, since JSON is not 100% the same as Javascript.
Actually, I guess the ask would be 'folding on arrays in the condensed version of any markup language' if YAML also does not fold in condensed version.
Today, I use a browser extension to browse and alter JSON's (including condensed version JSON with nested arrays). This extension can fold and unfold arrays and makes it very easy to explore and alter JSON's. I just thought it would be great if Geany could support this as well in a way that's practical for users, which would include the ability to fold and unfold arrays at different grains.
On 28 November 2014 at 01:29, arslaan beatboxa@users.sf.net wrote:
You need to add a lexer for Json to the editing component Scintilla
which is a separate project (www.scintilla.org). Then it can be used
in Geany.
Cheers
Lex
Related
Feature Requests:
#745Or just add support for folding on [], this should be trivial to add to LexCPP. I didn't really checked what consequence it'd have but I doubt it's be a problem with another language it supports, can probably be interesting in other languages this lexer support that use [] as array literals, and can always be controlled by a lexer property if needed.
Patch submitted to upstream: https://sourceforge.net/p/scintilla/feature-requests/1087/
Gotcha...Thanks for the recommendations and for submitting the patch / patch request!
Last edit: beatboxa 2014-11-29
Implemented in 1.25