Encode lanugage as a string instead of an array
This commit is contained in:
parent
831729b558
commit
77a84195f5
|
@ -82,7 +82,7 @@ public abstract class BaseResource extends BaseElement implements IResource {
|
|||
|
||||
private IdDt myId;
|
||||
|
||||
@Child(name = "language", order = 0, min = 0, max = Child.MAX_UNLIMITED)
|
||||
@Child(name = "language", order = 0, min = 0, max = 1)
|
||||
private CodeDt myLanguage;
|
||||
|
||||
private ResourceMetadataMap myResourceMetadata;
|
||||
|
|
|
@ -64,6 +64,7 @@ import ca.uhn.fhir.model.dstu2.valueset.IdentifierUseEnum;
|
|||
import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.UnknownContentCodeEnum;
|
||||
import ca.uhn.fhir.model.primitive.CodeDt;
|
||||
import ca.uhn.fhir.model.primitive.DateDt;
|
||||
import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
|
@ -496,7 +497,24 @@ public class JsonParserDstu2Test {
|
|||
assertThat(encoded, not(containsString("tag")));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testEncodeAndParseLanguage() {
|
||||
Patient p = new Patient();
|
||||
p.setLanguage(new CodeDt("en_CA"));
|
||||
|
||||
String encoded = ourCtx.newJsonParser().encodeResourceToString(p);
|
||||
ourLog.info(encoded);
|
||||
|
||||
assertEquals("{\"resourceType\":\"Patient\",\"language\":\"en_CA\"}", encoded);
|
||||
|
||||
p = (Patient) ourCtx.newJsonParser().parseResource(encoded);
|
||||
assertEquals("en_CA", p.getLanguage().getValue());
|
||||
|
||||
p = (Patient) ourCtx.newJsonParser().parseResource("{\"resourceType\":\"Patient\",\"language\":[\"en_CA\"]}");
|
||||
assertEquals("en_CA", p.getLanguage().getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* #158
|
||||
*/
|
||||
|
|
|
@ -213,6 +213,10 @@
|
|||
An example has been added which shows how to do this
|
||||
<![CDATA[<a href="./doc_custom_structures.html">here</a>]]>
|
||||
</action>
|
||||
<action type="fix">
|
||||
JSON parser was incorrectly encoding resource language attribute in JSON as an
|
||||
array instead of a string. Thanks to David Hay for reporting!
|
||||
</action>
|
||||
</release>
|
||||
<release version="1.5" date="2016-04-20">
|
||||
<action type="fix" issue="339">
|
||||
|
|
Loading…
Reference in New Issue