I need to map a location in JSON (or JavaScript object) defined by JSON-pointer to the position in JSON text file as {line,column}
. Is there any existing JavaScript library that would do it? Writing this code is going to be a bit tedious...
For example, if I have a JSON file (text):
{
"foo": [
{
"bar": 1
}
]
}
then given JSON-pointer /foo/0/bar
I need to get {line: 4, column: 7}
as the result.
If an 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}
.
We often need to convert JSON responses into a map to work with the returned JSON data easily. We can easily convert JSON data into a map because the JSON format is essentially a key-value pair grouping and the map also stores data in key-value pairs.
JSON Lines handles tabular data and clearly identifies data types without ambiguity. This allows records to be processed one at a time, which makes the format very useful for exporting and sending data.
Although it uses JavaScript syntax, it's language-independent, since the resultant is plain text. JSON Pointer ( RFC 6901) is a feature from JSON Processing 1.1 API ( JSR 374 ). It defines a String that can be used for accessing values on a JSON document. It can be related to what XPath does for an XML document.
To do so, simply select “File > Export As” and select the JSON file type. You can export json from the command line with the --export-map option. The fields found in the JSON format differ slightly from those in the TMX Map Format, but the meanings should remain the same.
This library has the equivalents of JSON.parse/stringify that also return mappings: https://github.com/epoberezkin/json-source-map
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With