How to get a JSON object back from a Jenkins build request
The nextBuildNumber may not be the correct build number in all cases. If you have triggered two different builds of the same Job, we don't know which one got triggered first. There is a race condition here. Checking the build queue may not give the correct build number either.
As soon as the build has been triggered, you can get its URL back from:
http://localhost/jenkins/job/job_name/api/json?tree=lastBuild[url]
This will return the running build if there is one, or the latest completed build otherwise. You can then add "/api/json" to that URL to get your build's JSON object.