And this is the confidence that we have in him, that, if we ask any thing according to his will, he hears us. (1 John 5:14, AKJV)
John has finished speaking about Jesus of Nazareth and now writes about prayer. Some have taken what the Lord Jesus said, "And whatever you shall ask in my name, that will I do, that the Father may be glorified in the Son. (John 14:13, AKJV)" to mean that whatever we pray must come to pass as we prayed for it. This view would have God as servant to praying people. This view, interpretation, is wrong writes John.
Confidence = has the idea of bluntness, plainly speaking and by extension has the idea of assurance, that is, what is said/written will happen. The idea here is that we can be bold to pray; we can speak freely to God himself of our needs and wants. "In whom we have boldness and access with confidence by the faith of him." (Ephesians 3:12, AKJV)
In him refers to the Lord Jesus, whom he has been writing about.
Note the condition. Whatever we pray/ask for must be according to His will. So what He approves of will be granted. That is why we pray, "If it is your will."
Some other conditions:
And whatever we ask, we receive of him, because we keep his commandments, and do those things that are pleasing in his sight. (1 John 3:22, AKJV)
You ask, and receive not, because you ask amiss, that you may consume it on your lusts. (James 4:3, AKJV)
Confess your faults one to another, and pray one for another, that you may be healed. The effectual fervent prayer of a righteous man avails much. (James 5:16, AKJV)
Hear = not only hearing it but granting the petition.
And if we know that he hear us, whatever we ask, we know that we have the petitions that we desired of him. (1 John 5:15, AKJV)