I joined a project were we sell services for different providers through web, iOS and android apps. I am working on iOS. I was ask to display a purchase form via a web view and react by what is entered natively. I do so by intercepting the network communication but as you can imagine it is slow, error prone and just kind of stupid. I ask why it has to be done in this way, why I just cannot get the data and render the form myself natively, and I was told that soon also the android app will adapt this feature and as the form can slightly change for each providers that would be the easiest approach.
While I agree that it is easier to decide on the server which fields are needed for each call, I don't think that the logical conclusion is to request a html form and create hackish interception around it.
Before the implementation for android starts I want to propose another option:
Instead of rendering a website I want the server to create a JSON to describe the form, that than can easily be used at client-side to create the form. Basically a server generated view model.
My question is: is there some "standard" already how such a JSON should look like?
I imagine it something like this
{
  "form": {
    "action": {
      "action-name": "Send",
      "method": "POST",
      "target": "https://api.mydomain.com/purchase/"
    },
    "fieldsets": [{
      "fieldset-name": "personal information",
      "fields": [{
        "field": {
          "kind": "text-field",
          "field-name": "First Name",
          "validator": {
            "validator-name": "regex-validator",
            "arguments": [{
              "regex": ".{3:}"
            }]
          },
          "optional": false
        }
      }, {
        "field": {
          "kind": "text-field",
          "field-name": "Last Name",
          "validator": {
            "validator-name": "regex-validator",
            "arguments": [{
              "regex": ".{3:}"
            }]
          },
          "optional": false
        }
      }, {
        "field": {
          "kind": "text-field",
          "field-name": "Email",
          "validator": {
            "validator-name": "email-validator"
          },
          "optional": false
        }
      }, {
        "field": {
          "kind": "text-field",
          "field-name": "Confirm Email",
          "validator": {
            "validator-name": "email-validator"
          },
          "optional": false
        }
      }]
    }, {
      "fieldset-name": "Credit Card Data",
      "fields": [{
        "field": {
          "kind": "text-field",
          "field-name": "Credit Card Number",
          "validator": {
            "validator-name": "creditcard-number-validator"
          },
          "optional": false
        }
      }]
    }]
  }
}