nifi-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Carenza <nick.care...@thecontrolgroup.com>
Subject Re: Json Validation for mandatory fields
Date Thu, 12 Jan 2017 16:54:53 GMT
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 <mattyb149@apache.org> 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 <selmna@gmail.com> 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 <markap14@hotmail.com>
> 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 <selmna@gmail.com> 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
> > "லஞ்சம் தவிர்த்து நெஞ்சம் நிமிர்த்து"
>

Mime
View raw message