-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Is it possible to add line number into the Report? #59
Comments
Well, that is not impossible, but it will be immensely difficult. For this, I'd need to parse by hand and retain all location information... And manage to maintain that information during parsing, and put it in reports. Which means I need to put it in the schema. This is all the more difficult that once the JSON is parsed into a |
Thanks for your quick response, hope this feature will be implemented later. |
Hello, Any update on this issue. I just found there's a Class in Jackson to trace the line location, please see the Class in http://jackson.codehaus.org/1.3.4/javadoc/org/codehaus/jackson/JsonLocation.html . Can we use this Class to add error line location into the report? Could you please tell me how to implement it? Thanks, |
I've done something like this before. |
Thanks for sharing the idea. Could you please send me the code implementation? Please send it to hai_lh@126.com. Thanks a lot!!! |
Hello, A gist showing how you do it would interest me as well. |
I'm also waiting for response from pmseltmann. |
My solution was in javascript but maybe it can still be helpful. I forked the popular jsonlint JSON parser to index the line numbers of the source string. The parser returns an object with the parsed json object and a lineIndex object containing an index with all the json key-paths and their corresponding line numbers. I used the tv4 json-schema validator (https://github.com/geraintluff/tv4) and used the resulting 'schema-key' from each error to lookup the original line number in my I then lookup the 'schema-key' from lineIndex object and get the line number. (I transform 'schema-key' to match the keyPath. Mostly converting '/' to '.'. |
With Jackson, it is a little more complicated ;) When using a parser, you do have In any event, this will be part of -core, not -validator. |
OK, this will be in for 3.0. I already have a |
Where is the JsonParser which can collect line number information? Is it part of another project? Do you mean you are changing Jackson itself? Any estimate on when 3.0 will be available? Sorry for all the questions. Thanks. |
@sellis the work is here; however, at this moment I am working on another of my projects; I will resume work on JSON Schema validator next month for a first beta release probably in mid July. |
Thanks a lot for your response! |
I have completed a project in java for json validation with line number using jackson. Basically as @fge has coorectly said, we have to maually parse the data and create JSONNode objects at runtime. Please let me know incase of any help is needed. |
@bharatsavanur11 |
@bharatsavanur11 , Can you please share your implementation over here or on email ostwalankit@gmail.com . It will help me solve my issue. I really appreciate your help. Thanks. |
It's different to locate the error in current Report format as follows for large JSON file. Is it possible to add line number into Report to denote which line is the pointer(schema or instance)?
com.github.fge.jsonschema.report.ListProcessingReport: failure---
BEGIN MESSAGES
---error: instance type does not match any allowed primitive type
level: "error"
schema: {"loadingURI":"#","pointer":"/properties/version"}
instance: {"pointer":"/version"}
domain: "validation"
keyword: "type"
expected: ["integer"]
found: "number"
--- END MESSAGES ---
Thanks,
Hai
The text was updated successfully, but these errors were encountered: