# JSON: Parsing from label:value structure

**URL:** <https://forum.openrefine.org/t/json-parsing-from-label-value-structure/2567>\
**Category:** Support and Helpdesk\
**Created:** [September 22, 2025, 10:20pm UTC](https://forum.openrefine.org/t/json-parsing-from-label-value-structure/2567 "2025-09-22T22:20:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcyzyk](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@mcyzyk](https://forum.openrefine.org/u/mcyzyk)\
**Post date:** [September 22, 2025, 10:20pm UTC](https://forum.openrefine.org/t/json-parsing-from-label-value-structure/2567/1 "2025-09-22T22:20:33Z")

</div>

All,

I have this chunk of JSON:

`"metadata" : [ `

`{ "label" : "Accession Number", "value" : "03547" }, `

`{ "label" : "File Name", "value" : "03547-2" }, `

`{ "label" : "Call number", "value" : "D657 L726t / 1-SIZE" }`

and I am trying to get values for, e.g., Accession Number, File Name, Call number.

So, for the label “Accession Number” I want to retrieve the value of `03547`

Trying everywhichway, No Joy.

The structure is sort of a dual key/value pair. Not sure how to parse. Searching for recipe...

Advice appreciated,

Mark

---

<div class="post-metadata">

**Author:** ![mcyzyk](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@mcyzyk](https://forum.openrefine.org/u/mcyzyk)\
**Post date:** [September 22, 2025, 11:59pm UTC](https://forum.openrefine.org/t/json-parsing-from-label-value-structure/2567/2 "2025-09-22T23:59:36Z")

</div>

What’s throwing me off here is that the JSON is literally saying “label” and “value” when “Accession Number” just is the label/name for an object (once the JSON is parsed out to JS) with its value being “03547”.

So it’s not just “get the value for Accession Number”:

parseJson(value).get("Accession Number")

Somehow, I need to read down the tree here?

metadata –\> “label” –\> with value of “Accession Number” –\> “value” –\> The Value I’m Looking For

---

<div class="post-metadata">

**Author:** ![mcyzyk](https://avatars.discourse-cdn.com/v4/letter/m/5f9b8f/32.png) [@mcyzyk](https://forum.openrefine.org/u/mcyzyk)\
**Post date:** [September 23, 2025, 1:52am UTC](https://forum.openrefine.org/t/json-parsing-from-label-value-structure/2567/3 "2025-09-23T01:52:20Z")

</div>

I had a couple rounds with CoPilot on this!

filter(parseJson(value)["sequences"][0]["canvases"][0]["metadata"], m, m["label"] == "Accession Number")[0]["value"]

Good to have a working example. Now studying it to learn exactly what it does.

---

<div class="post-metadata">

**Author:** ![thadguidry](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/thadguidry/32/653_2.png) [@thadguidry](https://forum.openrefine.org/u/thadguidry)\
**Post date:** [September 23, 2025, 2:12am UTC](https://forum.openrefine.org/t/json-parsing-from-label-value-structure/2567/4 "2025-09-23T02:12:14Z")

</div>

Have you consulted our OpenRefine Docs for the parseJson() function?

> **[GREL functions | OpenRefine](https://openrefine.org/docs/manual/grelfunctions#format-based-functions-json-html-xml)**
>
> Besides the reference guide below, OpenRefine's GitHub wiki has a page with many examples and recipes of frequently-used GREL functions.

---

<div class="post-metadata">

**Author:** ![tfmorris](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/tfmorris/32/17_2.png) [@tfmorris](https://forum.openrefine.org/u/tfmorris)\
**Post date:** [September 23, 2025, 2:17am UTC](https://forum.openrefine.org/t/json-parsing-from-label-value-structure/2567/5 "2025-09-23T02:17:21Z")

</div>

With a cell containing the following string:

{"metadata" : [{ "label" : "Accession Number", "value" : "03547" },{ "label" : "File Name", "value" : "03547-2" },{ "label" : "Call number", "value" : "D657 L726t / 1-SIZE" }]}

these two expressions should provide some ideas for starting points:

value.replace('"label" :','').replace(', "value"','').replace('{"metadata" : [','').replace('},{',',').parseJson()['File Name']

filter(forEach(value.parseJson().metadata,i,if(i.label =='File Name',i.value,'')),x,not(isBlank(x)))[0]

The first is kind of a hack which uses string manipulation to convert the JSON array to a JSON object with the label values as keys.  
The second iterates through the array and matches the label using an If function.

Tom
