Fix JSON encoding, where training '}' may not be written correctly for certain input buffer lengths
Need to get the current attribute from the cursor in READ_STATE_ATTR_END state