Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
602 views
in Technique[技术] by (71.8m points)

sublimetext3 - How do I fold by "{" in Sublime Text 3 if I have an array of JSON objects?

If I have the following array of JSON objects in Sublime, it will collapse at any "[". My ask is if this can be changed to fold at any "{"

Taking this JSON array

[{"a":[{"b":1,"c":2},{"d":3},{"x":99,"y":100}],"b":4},{"a":[{"b":5,"c":6}],"b":7}]

and pretty formatting it within the same file

[
  {
    "a": [
      {
        "b": 1,
        "c": 2
      },
      {
        "d": 3
      },
      {
        "x": 99,
        "y": 100
      }
    ],
    "b": 4
  },
  {
    "a": [
      {
        "b": 5,
        "c": 6
      }
    ],
    "b": 7
  }
]

As an example of it working mostly the way I am looking for, with the JSON below, it will collapse at any "{" with more than one element, so {"d":3} does not collapse:

{
  "a": [
    {
      "b": 1,
      "c": 2
    },
    {
      "d": 3
    },
    {
      "x": 99,
      "y": 100
    }
  ],
  "b": 4
}

Edit - it looks like if I take the formatted array into a new file, it will recognize all potential folding points.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...