diff --git a/src/Sitecore.AspNetCore.SDK.LayoutService.Client/Serialization/Fields/JsonSerializedField.cs b/src/Sitecore.AspNetCore.SDK.LayoutService.Client/Serialization/Fields/JsonSerializedField.cs
index ec4e340..508457d 100644
--- a/src/Sitecore.AspNetCore.SDK.LayoutService.Client/Serialization/Fields/JsonSerializedField.cs
+++ b/src/Sitecore.AspNetCore.SDK.LayoutService.Client/Serialization/Fields/JsonSerializedField.cs
@@ -18,6 +18,15 @@ public class JsonSerializedField(JsonDocument doc)
private readonly string _json = doc != null ? doc.RootElement.GetRawText() : throw new ArgumentNullException(nameof(doc));
+ ///
+ /// Gets the raw JSON string representation of the field.
+ ///
+ /// A string containing the raw JSON data.
+ public string GetRawValue()
+ {
+ return _json;
+ }
+
///
protected override object? HandleRead(Type type)
{
diff --git a/tests/Sitecore.AspNetCore.SDK.LayoutService.Client.Tests/Serialization/Fields/JsonSerializedFieldTests.cs b/tests/Sitecore.AspNetCore.SDK.LayoutService.Client.Tests/Serialization/Fields/JsonSerializedFieldTests.cs
index 2b5ec9a..cbe12c9 100644
--- a/tests/Sitecore.AspNetCore.SDK.LayoutService.Client.Tests/Serialization/Fields/JsonSerializedFieldTests.cs
+++ b/tests/Sitecore.AspNetCore.SDK.LayoutService.Client.Tests/Serialization/Fields/JsonSerializedFieldTests.cs
@@ -119,6 +119,21 @@ public void TryRead_InvalidJson_ThrowsException()
field.Should().BeNull();
}
+ [Fact]
+ public void GetRawValue_ReturnsExpectedJson()
+ {
+ // Arrange
+ const string json = "{\"value\": 100}";
+ JsonDocument token = JsonDocument.Parse(json);
+ JsonSerializedField sut = new(token);
+
+ // Act
+ string result = sut.GetRawValue();
+
+ // Assert
+ result.Should().Be(json);
+ }
+
private class ValueField : IField
{
public required T Value { get; set; }