I have been considering contributing a ValidateJsonSchema processor myself. According to json-schema.org, there are 3 validators in Java. Does anyone have experience with any of them and could support using one of another?
http://json-schema.org/implementations On Thu, Jan 12, 2017 at 8:29 AM, Matt Burgess <[email protected]> wrote: > Selvam, > > There was a ValidateJson processor submitted under NIFI-1893 [1], but > it used a library that has been deemed Category X so it had to be > removed. Hopefully it will be refactored and resubmitted. > > If you are not encumbered by the JSON.org license, you can build the > ValidateJson processor yourself or use ExecuteScript, I have an > example [2] that uses the same approach (with JSONSchema) to validate > the JSON. Alternatively you don't need JSONSchema to check for > missing fields, you can use Groovy's built-in JsonSlurper and just > check the parsed object to see if the field exists. I have an example > of using the slurper (and accessing the object fields) at [3]. > > Regards, > Matt > > [1] http://issues.apache.org/jira/browse/NIFI-1893 > [2] http://funnifi.blogspot.com/2016/05/validating-json-in-nifi-with.html > [3] http://funnifi.blogspot.com/2016/02/executescript-json-to- > json-conversion.html > > On Thu, Jan 12, 2017 at 11:06 AM, Selvam Raman <[email protected]> wrote: > > Thanks mark. > > > > I have already followed the same approach but we are having more than > fifty > > fields, so thinking about is there any other way? > > > > Thanks, > > selvam R > > > > On Thu, Jan 12, 2017 at 3:03 PM, Mark Payne <[email protected]> > wrote: > >> > >> Selvam, > >> > >> You can use EvaluateJsonPath to extract the particular JSON value into > an > >> attribute > >> and then use RouteOnAttribute to make sure that the field exists (and is > >> valid if necessary). > >> > >> For example, for EvalualteJsonPath you might use something like: > >> > >> name: $.person.name > >> > >> And then in RouteOnAttribute, you could use: > >> > >> missing.name: ${name:isEmpty()} > >> > >> If you have multiple fields to check on RouteOnAttribute, you could > create > >> a separate Relationship > >> for each rule by setting the "Routing Strategy" property to "Route to > >> Property Name" or you could > >> set the Routing Strategy to "Route to 'matched' if any matches" and then > >> the 'unmatched' relationship would indicate that the JSON is valid. > >> > >> Thanks > >> -Mark > >> > >> > >> On Jan 12, 2017, at 8:46 AM, Selvam Raman <[email protected]> wrote: > >> > >> Hi, > >> > >> I will get array of json files. There are some fields which are > mandatory > >> in json file, if not present i should not process file. > >> > >> How can i achieve it in nifi. > >> > >> -- > >> Selvam Raman > >> "லஞ்சம் தவிர்த்து நெஞ்சம் நிமிர்த்து" > >> > >> > > > > > > > > -- > > Selvam Raman > > "லஞ்சம் தவிர்த்து நெஞ்சம் நிமிர்த்து" >
