Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-incubator-e4-dev] Fw: Declarative UI roundup?

I played with JSON [1] some time ago and I think it is lacking the
notion of id/references and notion of type/class [2]. The only
structure elements you have are arrays and maps (which is ironically
called "object").

So, JSON might be OK when you have a schema and you know the
meaning of the attributes (id or reference), but you have to
introduce some artificial attributes to extract the "class" from
a map:

here is a simple "schema" using emfatic[2] syntax:

  class Control {
    id attr String id; // an id to be referenced
    attr String[*] name;
    ref Composite container; // ref means a reference to an id attribute
  }

  class Text extends Control {
    attr String text;
  }

  class Label extends Control {
    attr String text;
  }

  class Composite extends Widget {
    val Widget[*] widgets; // val means physically nested
  }

"native" JSON serialization cannot distinguish between a text

 {
   "id" : "Control1", // is this an ID or just a string
   "widgets" : [
      { // is this a Text or a Label???
         "id" : "Control2",
         "text" : "Control1", // is this a string or a reference???
         "container" : "Control1"
      },
      {
         "id" : "Control3",
         "text" : "foo bar",
         "container" : "Control1"
      }
   ]
 }

Without additional information (that goes beyond the JSON specs)
it is not possible to figure out if Control2 is a Text or a Label,
because JSON lacks the concept of typed object (or records).

In addition, without a "schema" it is not possible to figure out that
 - "id" : "Control1" defines an ID
 - "container" : "Control1" is a reference
 - "text" : "Control1" is NOT a reference

==> JSON is not self describing (that means: you can not infer
a kind of schema form a data file). And it is not "object
friendly" because you have to add application specific attributes
to specify "object types".

<flame>This *really* annoys me, because more than 20 years ago me
and others have "invented" and used simple self describing data
serialization formats that allow you to extract some (basic) schema
from a datafile. The whole XML (mess) (invented by linguists!) puts an
entire industry into a state where people spend a lot of time
into simple serialization, because it is made so incredibly complicated...

I think JSON is another "bad standard". With some minor enhancements
it could become a useful format for object serialization, but as it is
it is almost as bad as XML....
</flame>

Michael

[1] http://www.json.org/
    http://www.ietf.org/rfc/rfc4627.txt?number=4627
[2] http://michaelscharf.blogspot.com/2007/06/i-dont-like-xml-but-what-are.html
[3] http://wiki.eclipse.org/Emfatic


Ed Merks wrote:
David,

Marcelo has a prototype for a JSON serializer. One deficiency in JSON, which isn't apparent for its primary use case, is that you don't know the type of what you are reading. Starting at the root, you haven't clue and even when processing children, you never know if the actual data's type is of a class derived from the expected type of data. This makes it hard to create the right type of object in a strongly typed setting...

Cheers,
Ed


David Orme wrote:

This is interesting. XML is good in that it has tooling, but other formats are arguably even more wrist and eye-friendly. Given our web aspirations, JSON seems particularly interesting...

Ed- is there a JSON marshaller for EMF objects yet?

-Dave Orme

    On Nov 6, 2008 6:47 PM, "向雅" <fyaoxy@xxxxxxxxx
    <mailto:fyaoxy@xxxxxxxxx>> wrote:

    2 points: an UI declaration, and a thought.
    1.an <http://1.an> UI declaration:
    above sample can be like this:

    @layout: fill;
    label: "hello, world"; text{style: BORDER; layoutData: "grow"}

    Huge simple?  if yes, again:

    @layout: "fill";
    @StyleSheet{
           text{ style: SINGLE, BORDER;}
    };
    @forms: true;

    section{
           @id: loginSection;
           sectionStyle: ExpandableComposite.TITLE_BAR;
           CompositeSeparator:NONE;
           text: 登录系统;
           layoutData: "center";
           composite{
                   @id: sectionClient;
                   layout: "wrap 3", "[][250:pref:400,fill][]", "[]5[]";
                   label: 您的数字证书:;
                   text { @id: certFile; text: ""; }
                   button { @id: browse; text: 选择文件(&B)...; style:
    PUSH; }

                   label: 您的密码:;
                   text { @id: password; text: ""; style: PASSWORD; }
                   button { @id: login; text: "登录系统(&L)   ";
    style: PUSH; }
           }
           client: @sectionClient;
    }

    2, a thought: at this time, in the world, the most question is not can
    you do. instead, just be: How and what make better.Yes? like David
    style, I do answer, sure.:)

    Best! qinxian

    _______________________________________________
    eclipse-incubator-e4-dev mailing list
    eclipse-incubator-e4-dev@xxxxxxxxxxx
    <mailto:eclipse-incubator-e4-dev@xxxxxxxxxxx>
    https://dev.eclipse.org/mailman/listinfo/eclipse-incubator-e4-dev

------------------------------------------------------------------------

_______________________________________________
eclipse-incubator-e4-dev mailing list
eclipse-incubator-e4-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipse-incubator-e4-dev

------------------------------------------------------------------------

_______________________________________________
eclipse-incubator-e4-dev mailing list
eclipse-incubator-e4-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipse-incubator-e4-dev



Back to the top