I have a quick question.
Can I parse floating point variables with coreJSON? It should just be a case of getting the finding the corresponding token and using strtof() on the associated value string, correct?
I have a quick question.
Can I parse floating point variables with coreJSON? It should just be a case of getting the finding the corresponding token and using strtof() on the associated value string, correct?
You are exactly right. For a quick check, I added the following code to the coreJSON unit tests here:
double val;
jsonStatus = JSON_SearchT( JSON_DOC_VARIED_SCALARS,
JSON_DOC_VARIED_SCALARS_LENGTH,
"decimal",
7,
&outValue,
&outValueLength,
&outType );
printf( "Original Decimal Value: %.*s\n", ( int )outValueLength, outValue );
val = strtod( outValue, NULL );
printf( "Converted Decimal Value: %.8f\n", val );
And I get the following output:
Original Decimal Value: 109238.42091289
Converted Decimal Value: 109238.42091289