Skip to content

NeonRawValue

Paolo Rossi edited this page Feb 5, 2024 · 1 revision

NeonRawValue

The NeonRawValue attribute allows to serialize/deserialize properties or fields without quoting or escaping. This can be useful in the scenarios like when values already serialized in JSON or values have been already quoted.

Let’s see an example of using NeonRawValue :

TRawRec = record
  Count: Integer;
  [NeonRawValue]
  Raw: string;
end;

// assigning record values
LRaw.Count := 1234;
LRaw.Raw := '{"Name":"Paolo"}';

Without the NeonRawValue attribute you’ll get the property Raw treated as a normal string (quoted and escaped)

{
  "Count": 1234,
  "Raw": "{\"Name\":\"Paolo\"}"
}

With the NeonRawValue attribute you’ll get the property Raw treated as a “JSON” string, the value is inserted as is it in the resulting JSON

{
  "Count": 1234,
  "Raw": {
    "Name": "Paolo"
  }
}
Clone this wiki locally