It is already in JSON format.I tried to convert string to json.I got it.But the result is same as what it is in question.
When convert string to json it should be in \"Key\":\"Value\" or \"Key\":Value
NSString *str=@"[{\"SCHEME_NAME\":\"FUG RSA SCHEME\",\"Investment_Value\":-46719.00201558,\"Bid_Price\":2.2566,\"Bid_Price\":\"2.2566\",\"Total_Contributions\":0,\"Growth\":-46719.00201558,\"INVESTOR_ID\":5613,\"PFA_SCHEMEID\":1},{ \"MONTH_NAME\": \"Balance as at 07-07-2016\",\"EMPLOYEE_CONTRIBUTION\": 3433764.77,\"EMPLOYER_CONTRIBUTION\": 4381387.29,\"TOTAL_VALUE\": 7815152.06,\"TOTAL_UNITS\": 2782788.3885,\"TOTAL_FEE\": 0,\"TOTAL_CONTRIBUTION\": 7815152.06,\"Voluntary\": \"0.00\"},{\"MONTH_NAME\": \"July 2016\",\"EMPLOYEE_CONTRIBUTION\": 0,\"EMPLOYER_CONTRIBUTION\":0,\"TOTAL_VALUE\":0,\"TOTAL_UNITS\": -20703.2713,\"TOTAL_FEE\": 0,\"TOTAL_CONTRIBUTION\": 0,\"Voluntary\": \"0.00\"}]";
NSData *dataStr = [str dataUsingEncoding:NSUTF8StringEncoding];
id jsonData = [NSJSONSerialization JSONObjectWithData:dataStr options:0 error:nil];
NSLog(@"The converted string to json is %@",jsonData);
Now the Printed result is
The converted string to json is (
{
"Bid_Price" = "2.2566";
Growth = "-46719.00201558";
"INVESTOR_ID" = 5613;
"Investment_Value" = "-46719.00201558";
"PFA_SCHEMEID" = 1;
"SCHEME_NAME" = "FUG RSA SCHEME";
"Total_Contributions" = 0;
},
{
"EMPLOYEE_CONTRIBUTION" = "3433764.77";
"EMPLOYER_CONTRIBUTION" = "4381387.29";
"MONTH_NAME" = "Balance as at 07-07-2016";
"TOTAL_CONTRIBUTION" = "7815152.06";
"TOTAL_FEE" = 0;
"TOTAL_UNITS" = "2782788.3885";
"TOTAL_VALUE" = "7815152.06";
Voluntary = "0.00";
},
{
"EMPLOYEE_CONTRIBUTION" = 0;
"EMPLOYER_CONTRIBUTION" = 0;
"MONTH_NAME" = "July 2016";
"TOTAL_CONTRIBUTION" = 0;
"TOTAL_FEE" = 0;
"TOTAL_UNITS" = "-20703.2713";
"TOTAL_VALUE" = 0;
Voluntary = "0.00";
}
)
Then When I get the data into array
NSArray *arrJson = [NSJSONSerialization JSONObjectWithData:[str dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:nil];
NSLog(@"The arrjson is %@",arrJson);
The printed result is
The arrjson is (
{
"Bid_Price" = "2.2566";
Growth = "-46719.00201558";
"INVESTOR_ID" = 5613;
"Investment_Value" = "-46719.00201558";
"PFA_SCHEMEID" = 1;
"SCHEME_NAME" = "FUG RSA SCHEME";
"Total_Contributions" = 0;
},
{
"EMPLOYEE_CONTRIBUTION" = "3433764.77";
"EMPLOYER_CONTRIBUTION" = "4381387.29";
"MONTH_NAME" = "Balance as at 07-07-2016";
"TOTAL_CONTRIBUTION" = "7815152.06";
"TOTAL_FEE" = 0;
"TOTAL_UNITS" = "2782788.3885";
"TOTAL_VALUE" = "7815152.06";
Voluntary = "0.00";
},
{
"EMPLOYEE_CONTRIBUTION" = 0;
"EMPLOYER_CONTRIBUTION" = 0;
"MONTH_NAME" = "July 2016";
"TOTAL_CONTRIBUTION" = 0;
"TOTAL_FEE" = 0;
"TOTAL_UNITS" = "-20703.2713";
"TOTAL_VALUE" = 0;
Voluntary = "0.00";
}
)
Converting NSString to JSON
datasting to json