search and replace regex for JSON string -


I have a JSON string of some objects.

I

  • remove all keys,
  • 'alpha' at any child level or on any child

    Replace every key with the condition that if 'A' starts with and ends with 'z'.

    For example:

    I have json string:

      "{" A ": {" b ": 4}," b "{" C ": {" d ":" e "," awefz ": {" l ":" c "}}}," c ": {" abcz ":" here "}}"  
      "{" a ": {" b "4", "b": {"c" : "{" A:: {"d": "e"}}, "c": {}} "  

    after implementing regex 2):" {"D": "E", "alpha": {"L": "c"}}, "c": {"alpha": " Here I am just looking for those reges.

    I only need JSONString and regex (to search) as input .

    I'm the key I do not want to loop through the recursive L. O. By the levels I just want to use regex on the JSON string.

    Is there any solution? < P>

    regex 1:

     ,? \ S * "a [^" ] * Z "\ s *: [^}] +   

    Replace with: ''

    Output: {"A": {"b": 4}, "b": {"c": {"d": "e"}}}, "c": {}} "< / Code>

    Demo:

    regex 2:

      a [^ "* * z  Replace with  

    : alpha

    output:

      "{" a ": {" b ": 4 }, "b": {"c": {"D": "e", "alpha": {"l": "c"}}}, "c": {"alpha": "here"}} "  

    Demo:

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -