Search code examples
servicestackservicestack-text

How to handle JSV with a comma(,) containing value?


Assume we have a string as follows:

string employeeDetails=[{Id:100,Name:John,Address:#39 ,street ,Country},{Id:101,Name:Brein,Address:#79 ,street ,Country}];

This is how i am Deserialising my string.

JsvStringSerializer jsv = new JsvStringSerializer();
List<EmploymentDetails> employmentDetails = jsv.DeserializeFromString<List<EmploymentDetails>>(employeeDetails);

As a result i am getting each employee address upto first comman i.e.,

employeeDetail.Address value as "#39" instead of "#39 ,street ,Country"

This is happening due to JSV format with comma(,) as separated value.

How to handle this scenarios with JSV in ServiceStack? Thanks in Advance.


Solution

  • JSV uses CSV-style escaping where any string that requires escaping should be wrapped with double-quotes, e.g:

    Address:"#39 ,street ,Country"