JSON, rather than XML, as page description language?



I don’t know if this has been suggested before, but was there ever any thought given to add the possibility to use JSON, rather than XML, as the language to describe pages?

JSON is less wordy, so it is more compact, probably easier and faster to parse, and it is basically Javascript, so it is a technology that NativeScript already uses (CSS is sufficiently close to JSON anyway), so there would be even less to learn for novices.

Furthermore, JSON has now surpassed XML on Google Trends (link below), with XML having a downward trend and JSON an upward one. So, XML will eventually die.


Example JSON page:

  "Page": {
    "loaded": "onPageLoaded",
    "unloaded": "onPageUnloaded",
    "actionBarHidden": "false",
    "ActionBar": {
      "title": "{{ appName }}",
      "android.iconVisibility": "never",
      "NavigationButton": {
        "text": "Back",
        "tap": "{{ goBack }}",
        "android.systemIcon": "ic_menu_back",
        "visibility": "{{ canGoBack() ? 'visible' : 'collapsed' }}"
      "ActionBar.actionItems": {
        "ActionItem": {
          "text": "Help",
          "tap": "{{ onHelp }}",
          "ios.position": "right",
          "android.systemIcon": "ic_menu_help"
    "StackLayout": {
      "Button": {
        "text": "Create new page",
        "tap": "{{ onTap }}"

Link: https://trends.google.co.uk/trends/explore?q=json,xml


Hey @nativescriptrox

Using JSON to write the user interface is an interesting thought, but also very… unusual.

XML has been used to describe the visual elements in almost every technology I can think of (WPF, html, Android / iOS sdks to name a few).

And while the trend for the ‘xml’ search term may be going down, don’t forget that it is also used as means to store data. The ‘json’ format has been gaining popularity for the past several years because it is extensively used in web. Both have pros and cons, and it’s up to the developer or the team to choose how and when to use either.

Still, if you would rather write JSON instead of XML for your UI, you could find a xml <-> json serializer and hook to the prepare step of your builds to achieve what you are suggesting above.


Thoughts? I’m just getting comfortable with XML and now you want to change the rules! :relaxed:

No thanks, XML actually works very well as a markup language IMO.


Haha, it was just a thought :wink: