I've a requirement like dragable tree in my project. I've successfully converted mssql resultset to json.
But the end user is again dragging and dropping and totally changed the tree structure. Now I have the below json from the client.
[
  {
    "id": 1,
    "title": "1. dragon-breath",
    "items": [
      {
        "id": 10,
        "title": "1. dragon-breath.1",
        "items": [
          {
            "id": 100,
            "title": "1. dragon-breath.1.2",
            "items": [
              {
                "id": 1000,
                "title": "1. dragon-breath.1.2.3",
                "items": [],
                "pos": 3
              }
            ],
            "pos": 2
          },
          {
            "id": 101,
            "title": "1. dragon-breath.1.2",
            "items": [],
            "pos": 2
          }
        ],
        "pos": 1
      }
    ],
    "pos": 1
  },
  {
    "id": 102,
    "title": "1. dragon-breath.1.2",
    "items": [
      {
        "id": 1020,
        "title": "1. dragon-breath.1.2.1",
        "items": [],
        "pos": 1
      }
    ],
    "pos": 2
  },
  {
    "id": 1021,
    "title": "1. dragon-breath.1.2.1",
    "items": [],
    "pos": 1
  }
]
From the above json "pos" property is for MSSQL Hierarchyid value.
I am trying to regenerate the hierarchy id of each element, when this json posted back from the client.
I am requesting you people to help me. (spend 2 days no luck)