1

I'm facing JSON encoding issue.

I have submitted my data to server on below formate to save remarks.

{
Remarks = "test apple """ ";
}

Then while fetching the data from the server, I'm receiving different formate like output:

{
Remarks = "test apple \U00e2\U0080\U009c\U00e2\U0080\U009d\U00e2\U0080\U009d\U00e2\U0080\U009d\\n";
}

While submitting data I'm using JSON serialisation.

  NSData *jsonData
    = [NSJSONSerialization dataWithJSONObject: dict
                                      options: NSJSONWritingPrettyPrinted
                                        error: nil];

  if (jsonData)
  {
    NSString* jsonString
      = [[NSString alloc]
          initWithData: jsonData
              encoding: NSUTF8StringEncoding];
    NSLog(@"posting params: %@", jsonString);
  }

My question is why I'm not getting I have submitted. I'm facing only double quote (") and single (') symbols.

Any one have idea?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Yalamandarao
  • 3,852
  • 3
  • 20
  • 27

2 Answers2

0

You probably should escape your non-delimitating quotes : { Remarks = "test apple \"\"\" "; }

Florian Burel
  • 3,408
  • 1
  • 19
  • 20
0

iOS 11 has added "Smart Punctuation" to the keyboard settings.

This means when typing "Singapore" it will convert it to “Singapore”. The '"' are replaced by a '“' and '”' string. Those are different quotes.

So one option might be to also replace '“' and '”' by '\"'.

Smart Punctuation = No
Yalamandarao
  • 3,852
  • 3
  • 20
  • 27
  • Hi how to handle my code i am facing same issue with double quote : [{"fontFamily"="firstfont","fontURL"="https%3A%2F%2Fs3.amazonaws.com%2FAttachments%2F1295312%2FUmbrellaMarket.ttf%3FAWSAccessKeyId=AKIAIBQXWGUYOJ6RIHHA&Expires=1853589442&Signature=fY8146gswIkXYyuouOT90HPbOlA%253D"},{"fontFamily"="secondfont","fontURL"="https%3A%2F%2Fs3.amazonaws.com%2Fttachments%2F1295312%2FUmbrellaMarket.ttf%3FAWSAccessKeyId=AKIAIBQXWGUYOJ6RIHHA&Expires=1853589460&Signature=LKw3TMt9r9BPC9zmiw85tTktX1A%253D"}] – jaydev Oct 03 '18 at 07:22
  • when i am sending this code to server then i am getting error – jaydev Oct 03 '18 at 07:24