src/jdk/nashorn/internal/parser/JSONParser.java
Print this page
*** 347,356 ****
--- 347,360 ----
result = LiteralNode.newInstance(arrayToken, finish, elements);
break loop;
case COMMARIGHT:
next();
+ // check for trailing comma - not allowed in JSON
+ if (type == RBRACKET) {
+ throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
+ }
break;
default:
// Add expression element.
elements.add(jsonLiteral());
*** 386,395 ****
--- 390,403 ----
next();
break loop;
case COMMARIGHT:
next();
+ // check for trailing comma - not allowed in JSON
+ if (type == RBRACE) {
+ throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
+ }
break;
default:
// Get and add the next property.
final PropertyNode property = propertyAssignment();