# How can I Upload a json file and read to process data

**URL:** <https://community.jenkins.io/t/how-can-i-upload-a-json-file-and-read-to-process-data/29353>\
**Category:** Community\
**Tags:** pipeline\
**Created:** [April 4, 2025, 5:32am UTC](https://community.jenkins.io/t/how-can-i-upload-a-json-file-and-read-to-process-data/29353 "2025-04-04T05:32:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hb7799](https://avatars.discourse-cdn.com/v4/letter/h/bc79bd/32.png) [@hb7799](https://community.jenkins.io/u/hb7799)\
**Post date:** [April 4, 2025, 5:32am UTC](https://community.jenkins.io/t/how-can-i-upload-a-json-file-and-read-to-process-data/29353/1 "2025-04-04T05:32:40Z")

</div>

I am trying to access json file using parameter (tried file, stashed) so that I can read content of file(key, value) and process the content. I am not able to read the file successfully. I have tried multiple ways: some examples are here:  
properties([  
parameters([  
file(name: ‘uploadFile’, description: ‘Upload Secrets JSON file’),  
base64File(name: ‘FILE’, description: “File to read”),  
stashedFile(name: ‘large’),  
)  
])  
])  
pipeline {  
agent any  
stages {  
stage('read multiple key values ') {  
steps {  
echo “Before Script”  
script {  
echo “Add Multiple Secrets to Key Vault”  
unstash ‘large’  
sh(script: ‘cat large’, returnStdout: true)

```
                    echo "END UNSTASH"
                    withFileParameter('FILE') {
                        sh(script: 'cat $FILE', returnStdout: true)
                        echo "END withFileParameter"

                        def jsonFilePath = large
                        echo "File PAth: ${jsonFilePath}"
                        def secrets = readJSON file: jsonFilePath
                        secrets.each { secret ->
                            if (secret.name && secret.value) {
                                echo "Adding secret ${secret.name} to Key Vault"

                            } else {
                                echo "Secret name or value is missing"
                            }
                        }
                    }   
                } 
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [April 4, 2025, 7:41am UTC](https://community.jenkins.io/t/how-can-i-upload-a-json-file-and-read-to-process-data/29353/2 "2025-04-04T07:41:01Z")

</div>

This works.  
Created a `stashedFile` parameter with name `stashed` and using this script:

```auto
pipeline {
    agent {
        label 'built-in'
    }
    stages {
        stage("run") {
            steps {
                script {
                    withFileParameter('stashed') {
                        def j = readJSON file: stashed, text: ''
                        echo j.message
                    }
                }
           }
        }
    }
}

```
