File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
main/java/com/saasquatch/jsonschemainferrer
test/java/com/saasquatch/jsonschemainferrer Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -211,12 +211,12 @@ static int getSerializedTextLength(@Nonnull JsonNode jsonNode) {
211211 return getBase64Length (binaryValue .length );
212212 } else if (isTextualFloat (jsonNode )) {
213213 // Handle NaN and infinity
214- return jsonNode .asText ().length ();
214+ return jsonNode .asString ().length ();
215215 }
216- final String textValue = jsonNode .textValue ();
217- if (textValue == null ) {
216+ if (!jsonNode .isString ()) {
218217 return -1 ;
219218 }
219+ final String textValue = jsonNode .stringValue ();
220220 // DO NOT use String.length()
221221 return textValue .codePointCount (0 , textValue .length ());
222222 }
Original file line number Diff line number Diff line change @@ -610,7 +610,8 @@ public void testEnum() {
610610 final JsonNode anyOf = schema .get ("anyOf" );
611611 assertTrue (anyOf .isArray ());
612612 assertTrue (
613- stream (anyOf ).anyMatch (_anyOf -> _anyOf .path ("enum" ).get (0 ).stringValue ().equals ("MARCH" )));
613+ stream (anyOf ).anyMatch (
614+ _anyOf -> _anyOf .path ("enum" ).get (0 ).stringValue ().equals ("MARCH" )));
614615 assertTrue (stream (anyOf )
615616 .anyMatch (_anyOf -> _anyOf .path ("enum" ).get (0 ).stringValue ().equals ("TUESDAY" )));
616617 }
@@ -699,8 +700,8 @@ public void testStringLengthFeatures() {
699700 .setStringLengthFeatures (EnumSet .allOf (StringLengthFeature .class ))
700701 .build ();
701702 final ObjectNode schema = inferrer .inferForSample (shouldBeText );
702- assertEquals (shouldBeText .asText ().length (), schema .path ("minLength" ).intValue ());
703- assertEquals (shouldBeText .asText ().length (), schema .path ("maxLength" ).intValue ());
703+ assertEquals (shouldBeText .asString ().length (), schema .path ("minLength" ).intValue ());
704+ assertEquals (shouldBeText .asString ().length (), schema .path ("maxLength" ).intValue ());
704705 }
705706 }
706707
You can’t perform that action at this time.
0 commit comments