ciava.at

Problem querydata with newline (\ and newline, tab ect)

Discussion created by ciava.at on Dec 29, 2011
Latest reply on Jan 9, 2012 by ciava.at
I have a value in a field string example "Test /n Test1...".
If I publish a mapserver and I do a request rest query with response type json: it returns "Test //n Test1..." but from json.org for newline in string I use /n. In rest esri uses QueryData because I have tried with this method and I have same response but if I use IRecordset I have no problem.


ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
 IRecordSet pNewRs  = new RecordSet();
 IRecordSetInit prsInit = pNewRs as IRecordSetInit;

 IFields pFields = new Fields();
 IFieldsEdit pFieldsEdit = pFields as IFieldsEdit;
 pFieldsEdit.FieldCount_2 = 2;

 IField pField = new Field();
 IFieldEdit pFieldEdit = pField as IFieldEdit;
 pFieldEdit.Name_2 = "Type";
 pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
 pFieldEdit.Length_2 = 50;
 pFieldsEdit.set_Field(0,pField);

 pField = new Field();
 pFieldEdit = pField as IFieldEdit;

 pFieldEdit.Name_2 = "Area";
 pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
 pFieldsEdit.set_Field(1,pField);

 prsInit.CreateTable(pFields);

 ICursor pIC = prsInit.Insert();
 IRowBuffer pRowBuf = prsInit.CreateRowBuffer();

 
 pRowBuf.set_Value(0, "Test /n Test1");
 pRowBuf.set_Value(1, 10.2);
 pIC.InsertRow(pRowBuf);
 

 byte[] fs = Conversion.ToJson(pNewRs);
 using (System.IO.FileStream f = new System.IO.FileStream(@"c:\test.txt", System.IO.FileMode.Create))
 {
  f.Write(fs, 0, fs.Length);
  f.Flush();
  f.Close();
 }



I have "Test \n Test1" in test.txt:
{"displayFieldName":"","fieldAliases":{"Type":"Type","Area":"Area"},"fields":[{"name":"Type","type":"esriFieldTypeString","alias":"Type","length":50},{"name":"Area","type":"esriFieldTypeDouble","alias":"Area"}],"features":[{"attributes":{"Type":"Test \n Test1","Area":10.2}}]}

Outcomes