-
Notifications
You must be signed in to change notification settings - Fork 19
Offer API to expose source maps of parsed JSON documents #12
Comments
Sounds like a feature I'd welcome! I could try to hack it together.
|
@kylef Okay, here's a working implementation on a branch, I'll wait for your feedback before I merge it. Call this: let json: ParsedJsonToken = try Jay().annotatedTypesafeJsonFromData(data) and it returns public struct ParsedJsonToken {
public let value: ParsedJsonValue
public let range: JsonRange
} |
This looks awesome, I'd say go with index since line number can always be found out afterwards and it's more accurate (if the JSON document wasn't pretty printed and in a single line). You can also change all of the errors thrown from Jay to contain source annotations too so people can easily find where a problem lies in their JSON document. I will try find some time tomorrow evening to try and use this. I'd also like to update my JSONSchema library to use Jay and try these source annotations. Would be helpful to indicate where validation warnings are raised from within the JSON document. |
Great, give it a try and let me know what you want changed. Happy to see
|
In some cases, I could see a use for having source maps for parsed JSON documents. For example, the character positions of parse JSON elements.
What do you think about this?
An example use-case could be for using JSON data used in tests and providing the exact location of a failure in a test.
The text was updated successfully, but these errors were encountered: