Forum: Ruby How to generate JSON at runtime with nested structure?

137bdf943917916b8e48cf23df6a06bf?d=identicon&s=25 Seema Khalkar (seemak)
on 2014-04-01 16:15
Attachment: input.json (761 Bytes)
Hi,
How can I create json file at runtime in Ruby with nested structure.

My JSON Format is

{
    "id": "0",
    "lockVersion": 0,
    "name": "seema",
    "description": "Rest-Cloud-SeemaKhalkar_100",
    "cloudProviderTypeRef": {
      "id": "1"
    },
    "host": "",
    "proxyUrl": "",
    "credential": {
      "userName": "leander1",
      "passKey": "vmware",
      "encrypted": false,
      "type": "PASSWORD"
    },
    "properties": [
      {
        "propertyDefinition": {
          "id": "1023",
          "lockVersion": 0,
          "name": "PLAB-ORG",
          "description": "PLAb-ORG Organization",
          "key": "organization",
          "type": "STRING",
          "secure": false,
          "required": false
        },
        "value": "PLAB-ORG",
        "overrideable": false
      }
    ]
  }
I wan't to generate it at runtime with dynamic keys as well as values.
what is the best solution for it?
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.