Skip to content

Commit 6752fa1

Browse files
committed
Fix json serialization of UncontrolledSubject
1 parent c29c3b3 commit 6752fa1

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/Fields/UncontrolledSubject.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22

33
namespace Scriptotek\Marc\Fields;
44

5-
class UncontrolledSubject extends Subfield implements SubjectInterface
5+
class UncontrolledSubject extends Subfield implements SubjectInterface, \JsonSerializable
66
{
7-
/**
8-
* @var array List of properties to be included when serializing the record using the `toArray()` method.
9-
*/
10-
public $properties = ['type', 'vocabulary', 'term', 'id'];
11-
127
public function getType()
138
{
149
return Subject::UNCONTROLLED_INDEX_TERM;
@@ -41,4 +36,13 @@ public function __toString()
4136
{
4237
return $this->getTerm();
4338
}
39+
40+
public function jsonSerialize()
41+
{
42+
return [
43+
'type' => $this->getType(),
44+
'term' => $this->getTerm(),
45+
];
46+
}
47+
4448
}

tests/data/examples/bibliographic2.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@
3636
"vocabulary": "tekord",
3737
"term": "Optiske instrumenter"
3838
},
39-
"akustooptiske",
40-
"effekter",
41-
"komponenter"
39+
{
40+
"type": "653",
41+
"term": "akustooptiske"
42+
},
43+
{
44+
"type": "653",
45+
"term": "effekter"
46+
},
47+
{
48+
"type": "653",
49+
"term": "komponenter"
50+
}
4251
]
43-
}
52+
}

0 commit comments

Comments
 (0)