[SalesForce] JSON Parser getCurrentToken()

I have a JSON string that I want to parse out. I have use the below code many times but for whatever reason this time it is not working. Can anyone poke any holes in this logic? Or point out why this may not be the best way to parse through a string?

String tokencred = [{"Id":"003m000000yKLySkkL","Token":"I2j5bUky04B4eLJGYELV"}]

    JSONParser parser = JSON.createParser(tokencred);
    //parse and map the returned string
    while (parser.nextToken() != null) {
        String parsedId;
        String parsedToken;
        if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'Id')) {
            parser.nextToken();
            parsedId = parser.getText();
        }
        if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && (parser.getText() == 'Token')) {
            parser.nextToken();
            parsedToken = parser.getText();
        }
        tokenCredMap.put(parsedId,parsedToken);
    }
    system.debug('tokenCredMap:: ' + tokenCredMap);

14:31:15.0 (808193208)|USER_DEBUG|[153]|DEBUG|tokenCredMap:: {null=null, 003m000000yKLySkkL=null}

I do need the map as there is additional logic that will enable me to have multiple token/id combos.

UPDATE:

15:02:55.11 (726597242)|USER_DEBUG|[314]|DEBUG|this is the updated value [{"Id":"00Qm0000009qqdiEAA","Token":"J5h8yz004mFJi44ozuhw"}]
15:02:55.11 (727270334)|USER_DEBUG|[323]|DEBUG|fieldName: Id
15:02:55.11 (727412370)|USER_DEBUG|[323]|DEBUG|fieldName: Token
15:02:55.11 (727597218)|USER_DEBUG|[342]|DEBUG|tokenCredMap:: {null=null, 00Qm0000009qqdiEAA=null}
15:02:55.11 (732474914)|DML_BEGIN|[360]|Op:Update|Type:Lead|Rows:1

Best Answer

I think the issue is that you are not advancing the parser after saving the ParsedId. Let's say that the if statement for the Id is evaluated as true. You then save the ParsedId, but you are not advancing the parser forward afterwords. That means the second If statement can never be true because the parser is still pointing to the value of the Id.