Map JSON pointer to a row {row, column} in a JSON text file

I need to display the location in JSON (or a JavaScript object) defined by a JSON pointer to a position in a JSON text file, like {line,column}. Is there any existing JavaScript library that would do this? Writing this code will be a little tedious ...

For example, if I have a JSON file (text):

{
  "foo": [
    {
      "bar": 1
    }
  ]
}

then the given JSON pointer /foo/0/barI need to get {line: 4, column: 7}as a result.

If the equivalent JSON value is stored in this JSON file:

{"foo":[{"bar":1}]}

then the result for the same JSON pointer should be {line: 1, column: 10}.

+4
source share
1
+2

Source: https://habr.com/ru/post/1666165/


All Articles