-1

First of all, Sorry, I'm newbie in Regular Expression so I cannot found the format for my RegEx.

I have a string like this :

{
   "xs:schema" : {
      "xs:element" : {
         "xs:complexType" : {
            "xs:choice" : {
               "xs:element" : {
                  "xs:complexType" : {
                     "xs:sequence" : {
                        "xs:element":null
                     }
                  }
               }
            }
         }
      }
   },
   "diffgr:diffgram" : {
      "NewDataSet" : {
         "Table" : {
            "Item1" : 12345,
            "Item2":"Part"
         }
      }
   }
}

I want select just this part of my string:

  "NewDataSet" : {
     "Table" : {
        "Item1" : 12345,
        "Item2":"Part"
     }
  }

how can I do it ?

MajAfy
  • 3,007
  • 10
  • 47
  • 83

1 Answers1

1

You're going to solve this easily just using JSON serialization. For example:

var obj = JSON.parse(jsonText);
var partOfJson = JSON.stringify(obj["diffgr:diffgram"]);

OP said somewhere:

Thanks but JSON name is diffgr:diffgram I don't know how can I call this !

In JavaScript, objects can be used as associative arrays or even dictionaries. That is, their properties can be retrieved using key-value syntax instead of dot syntax.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
  • Thanks for your comment "In JavaScript, objects can be used as associative arrays or even dictionaries", I forgot this option, Thanks – MajAfy Mar 08 '15 at 10:37