Both are correct, and it depends on the context which one should be used. は works as the contrastive marker there, so it connotes, for instance, "(I understand Japanese a little, but) I don't understand Chinese at all, I understand French very well, etc." Thus, if you just want to say "I understand Japanese a little" without any connotation for instance in your self-introduction, が is more appropriate, but if you say this after "I'm good at Spanish", は is more natural.