@@ -411,7 +411,7 @@ public boolean isExpectedStartArrayToken()
411
411
//System.out.println(" isExpectedArrayStart: OBJ->Array, wraps now: "+_parsingContext.getNamesToWrap());
412
412
// And just in case a field name was to be returned, wipe it
413
413
_nextToken = null ;
414
- // and last thing, [Issue #33], better ignore attributes
414
+ // and last thing, [dataformat-xml #33], better ignore attributes
415
415
_xmlTokens .skipAttributes ();
416
416
return true ;
417
417
}
@@ -422,7 +422,7 @@ public boolean isExpectedStartArrayToken()
422
422
// DEBUGGING
423
423
/*
424
424
@Override
425
- public JsonToken nextToken() throws IOException, JsonParseException
425
+ public JsonToken nextToken() throws IOException
426
426
{
427
427
JsonToken t = nextToken0();
428
428
if (t != null) {
@@ -444,7 +444,7 @@ public JsonToken nextToken() throws IOException, JsonParseException
444
444
@ Override
445
445
public JsonToken nextToken () throws IOException
446
446
{
447
- _binaryValue = null ; // to fix [Issue-29]
447
+ _binaryValue = null ;
448
448
if (_nextToken != null ) {
449
449
JsonToken t = _nextToken ;
450
450
_currToken = t ;
@@ -471,9 +471,8 @@ public JsonToken nextToken() throws IOException
471
471
}
472
472
int token = _xmlTokens .next ();
473
473
474
- /* Need to have a loop just because we may have to eat/convert
475
- * a start-element that indicates an array element.
476
- */
474
+ // Need to have a loop just because we may have to eat/convert
475
+ // a start-element that indicates an array element.
477
476
while (token == XmlTokenStream .XML_START_ELEMENT ) {
478
477
// If we thought we might get leaf, no such luck
479
478
if (_mayBeLeaf ) {
@@ -483,28 +482,24 @@ public JsonToken nextToken() throws IOException
483
482
return (_currToken = JsonToken .START_OBJECT );
484
483
}
485
484
if (_parsingContext .inArray ()) {
486
- /* Yup: in array, so this element could be verified; but it won't be reported
487
- * anyway, and we need to process following event.
488
- */
485
+ // Yup: in array, so this element could be verified; but it won't be
486
+ // reported anyway, and we need to process following event.
489
487
token = _xmlTokens .next ();
490
488
_mayBeLeaf = true ;
491
489
continue ;
492
490
}
493
491
String name = _xmlTokens .getLocalName ();
494
492
_parsingContext .setCurrentName (name );
495
493
496
- /* Ok: virtual wrapping can be done by simply repeating
497
- * current START_ELEMENT. Couple of ways to do it; but
498
- * start by making _xmlTokens replay the thing...
499
- */
494
+ // Ok: virtual wrapping can be done by simply repeating current START_ELEMENT.
495
+ // Couple of ways to do it; but start by making _xmlTokens replay the thing...
500
496
if (_namesToWrap != null && _namesToWrap .contains (name )) {
501
497
_xmlTokens .repeatStartElement ();
502
498
}
503
499
504
500
_mayBeLeaf = true ;
505
- /* Ok: in array context we need to skip reporting field names. But what's the best way
506
- * to find next token?
507
- */
501
+ // Ok: in array context we need to skip reporting field names.
502
+ // But what's the best way to find next token?
508
503
return (_currToken = JsonToken .FIELD_NAME );
509
504
}
510
505
@@ -555,8 +550,17 @@ public JsonToken nextToken() throws IOException
555
550
}
556
551
}
557
552
return (_currToken = JsonToken .VALUE_STRING );
553
+ } else {
554
+ // [dataformat-xml#177]: empty text may also need to be skipped
555
+ if (_parsingContext .inObject ()
556
+ && (_currToken != JsonToken .FIELD_NAME ) && _isEmpty (_currText )) {
557
+ _currToken = JsonToken .END_OBJECT ;
558
+ _parsingContext = _parsingContext .getParent ();
559
+ _namesToWrap = _parsingContext .getNamesToWrap ();
560
+ return _currToken ;
561
+ }
558
562
}
559
- // If not a leaf, need to transform into property...
563
+ // If not a leaf (or otherwise ignorable) , need to transform into property...
560
564
_parsingContext .setCurrentName (_cfgNameForTextElement );
561
565
_nextToken = JsonToken .VALUE_STRING ;
562
566
return (_currToken = JsonToken .FIELD_NAME );
0 commit comments