Jump to content
Sign in to follow this  
thomh

UnEscape JSON string

Recommended Posts

I am using the TJsonTextWriter to write my JSON string. Looking at the code I see this method which uses the WriteEscapedString method to escape the string.

 

procedure TJsonTextWriter.WriteValue(const Value: string);
begin
  inherited WriteValue(Value);
  if (Length(Value) = 0) and (EmptyValueHandling = TJsonEmptyValueHandling.Null) then
    Exit;
  WriteEscapedString(Value, True);
end;

 

But I cannot find an UnEscape JSON string method? Is there one?

 

Thanks,
Thom
 

Share this post


Link to post
  var JSONValue := TJSONObject.ParseJSONValue('"multi\nline"');
  Writeln(JSONValue.Value);
  JSONValue.Free;

yields

Quote

multi

line

 

  • Like 1

Share this post


Link to post
On 5/14/2021 at 10:06 AM, 0x8000FFFF said:

  var JSONValue := TJSONObject.ParseJSONValue('"multi\nline"');
  Writeln(JSONValue.Value);
  JSONValue.Free;

yields

 

Thank you.

 

BTW, is there a method that you can use to unescape the whole JSON string and not just a certain value?

 

// Thom

 

Share this post


Link to post

What do you mean, what is the difference between 'the whole JSON string' and 'a certaing value'? Can you name some examples?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×