picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.58k stars 326 forks source link

JSON Serialization needs documenting #391

Open rmunn opened 8 years ago

rmunn commented 8 years ago

It would be nice to have some documentation on the Wiki about how to write an ETO JSON file (a .jeto file) by hand. (It would be even nicer to have a designer like Glade, but that's a big project). The Visual Studio addon is very nice to have, and I've managed to muddle my way through a little bit by looking at the API and making JSON objects with names that seem right. But some things are tricky, and some documentation of the right way to do it would really help.

For example, it took me a long time to figure out how to write the spacing for a TableLayout. I thought it would be something like "Spacing": [ 15, 10 ] or "Spacing": { "$type": "Size", "Height": 10, "Width": 15" }. It was only by accident that I discovered that the right syntax was "Spacing": "15, 10".

It would also be nice to be able to write "Padding": 10 instead of "Padding": "10" (I get System.NotSupportedException: PaddingConverter cannot convert from System.Int64 when I try the former). And likewise, I think that "Spacing": [ 15, 10 ] should work as well as "Spacing": "15, 10". But these are separate issues: the main issue is that JSON seems like a very good syntax for writing Eto.Forms objects declaratively, but it really needs some documentation before people will really be able to use it.

cwensley commented 8 years ago

Thanks for reporting the issue! I agree that there needs to be some documentation regarding the json (and xaml) serialization especially now that the VS (and soon XS) will include templates for them.

I hope to get some of the documentation done soon to help users get up to speed with these new ways to define their views.

With regards to defining Spacing, I agree that it would be nice to be able to specify a numeric value directly, and/or an array of numeric values. Same goes for Size and Rectangle structs. It shouldn't be difficult to add this, and I think would make much more sense than specifying a string value only.

rmunn commented 8 years ago

Hmm, for Rectangles it might make sense to accept both [ 1, 2, 3, 4 ] and [ [1,2], [3,4] ] for a rectangle at point (1,2) with width 3 and height 4. As well as the string "1,2,3,4".

Also, I'll note that there seems to be a difference in behavior between the preview pane and the actual JsonReader.Load call. When I try to use "Padding": "10" in a Form, the preview pane loads that just fine but the actual code throws an exception. I'll create a new issue to track that one, though.

rmunn commented 8 years ago

Okay, created https://github.com/picoe/Eto/issues/393 to track the problem with "Padding" (and "Spacing", too).

magoerlich commented 11 months ago

Is this still an active issue? Or was already some documentation for the JSON Serialization created?

I could find some things about the XML and examples for it, but not that much about the jato....and i really dislike XML, just personally, nothing technical :D

So, is there already anything? Currently it would be nice to know how to use embedded Resources, like described for xml on this page.

I already tried:

    "Image": {
        "Resource": "EtoApp1.Images.tray.png"
    },

and

    "Image":  "Resource EtoApp1.Images.tray.png, EtoApp1",

and of course:

    "Image":  "{Resource EtoApp1.Images.tray.png}",

and

    "Image":  "{Resource EtoApp1.Images.tray.png, EtoApp1}",

none of it works.

But I'm sure more questions will arise and having some docs would be nice