Skip to content

Experimental dataset JSON GET API returns multi-valued fields as arrays#12488

Open
stevenwinship wants to merge 2 commits into
developfrom
9495-return-multi-valued-fields-as-arrays
Open

Experimental dataset JSON GET API returns multi-valued fields as arrays#12488
stevenwinship wants to merge 2 commits into
developfrom
9495-return-multi-valued-fields-as-arrays

Conversation

@stevenwinship

Copy link
Copy Markdown
Contributor

What this PR does / why we need it: For API GET /api/datasets/{id}/metadata multi-valued field values are not returned as arrays if only 1 entry exists. This causes parsing the JSON to be more complex.

Which issue(s) this PR closes: #9495

Special notes for your reviewer: Since the fields are parsed as an array, when more than 1 entry exists, there is no break in backward compatibility.

Suggestions on how to test this: Create a dataset with 1 subject and another with more than 1 subject. Examine the JSON output to see that the "subject": ["Medicine, Health and Life Sciences"] is always surrounded with []. This will happen for all fields that have DatasetFieldType.isAllowMultiples() (for reference "title" does not allow multiples)

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Is there a release notes update needed for this change?: Included

Additional documentation:

@stevenwinship stevenwinship self-assigned this Jun 25, 2026
@stevenwinship stevenwinship moved this to In Progress 💻 in IQSS Dataverse Project Jun 25, 2026
@stevenwinship stevenwinship added FY26 Sprint 26 FY26 Sprint 26 (2026-06-17 - 2026-07-01) Feature: API Original size: 20 Size: 10 A percentage of a sprint. 7 hours. Type: Bug a defect User Role: API User Makes use of APIs labels Jun 25, 2026
@github-actions github-actions Bot added the FY25 Sprint 26 FY25 Sprint 26 (2025-06-18 - 2025-07-02) label Jun 25, 2026
// Add metadata value to aggregation, suppress array when multiples not allowed
JsonArray valArray = vals.build();
return (valArray.size() != 1) ? valArray : valArray.get(0);
return (dfType.isAllowMultiples()) ? valArray : valArray.get(0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make changes to the OREMap, you need to update the version as noted at

//NOTE: Update this value whenever the output of this class is changed
private static final String DATAVERSE_ORE_FORMAT_VERSION = "Dataverse OREMap Format v1.0.3";
. This could also break archiving and tools such as DVUploader that can read archival bags to restore datasets. Hopefully those are robust enough to this change, but they presumably have code to parse single values that will now be obsolete.

@stevenwinship stevenwinship Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update the version (even though the output really doesn't change) and check DVUploader. DVUploader and anyone using the API should have no issue with the array since it is there when more than 1 entry is there.

@coveralls

coveralls commented Jun 25, 2026

Copy link
Copy Markdown

Coverage Status

Coverage is 25.024%9495-return-multi-valued-fields-as-arrays into develop. No base build found for develop.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:9495-return-multi-valued-fields-as-arrays
ghcr.io/gdcc/configbaker:9495-return-multi-valued-fields-as-arrays

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

@github-actions

Copy link
Copy Markdown

Test Results

403 tests   388 ✅  33m 4s ⏱️
 55 suites   15 💤
 55 files      0 ❌

Results for commit 190d915.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature: API FY25 Sprint 26 FY25 Sprint 26 (2025-06-18 - 2025-07-02) FY26 Sprint 26 FY26 Sprint 26 (2026-06-17 - 2026-07-01) Original size: 20 Size: 10 A percentage of a sprint. 7 hours. Type: Bug a defect User Role: API User Makes use of APIs

Projects

Status: In Progress 💻

Development

Successfully merging this pull request may close these issues.

Experimental dataset JSON GET API doesn't return multi-valued fields as arrays

3 participants