0

I'm facing problems with RapidJSON using on my embedded target. Under Windows everything works like a charm.

The following simple test does not work on my target:

#include "rapidjson/document.h"
#include "rapidjson/prettywriter.h"
#include "rapidjson/error/en.h"

using namespace rapidjson;

std::string temp = "{ \"Checksum\": 12345678912344567, \"Parameters\": [ 1, 2, 3 ] }" ;

Document json;
json.Parse( temp.c_str() );

if ( json.HasParseError() )
{
    Logger::Log( Logger::ERROR, GetParseError_En( json.GetParseError() ),
                                "Read" );
    return NULL;
}

if ( !json.IsObject() )
{
   Logger::Log( Logger::ERROR, "Problems parsing the JSON file: " + filename,
                               "Read" );
   return NULL;
}

The parsing doesn't return any error. If add an error the JSON, RapidJSON correctly reports the error (on the target, as well).

Get getting the type with json.GetType() returns 180 (dec) and IsInt64(), IsUint64() and IsDouble() return true.

Results of getters:

json.GetUint64() -> 269079258591236 
json.GetInt64()  -> 269079258591236 
json.GetDouble() -> 0

My compiler flags:

gnu_arm_4.7.4_20130913/bin/arm-none-eabi-g++.exe -DBOOST_ALL_NO_LIB -DBOOST_HAS_STDINT_H \
-DBOOST_LEXICAL_CAST_ASSUME_C_LOCALE -DBOOST_NO_STD_LOCALE -DBSPCFG_ENABLE_CPP -DMQX_ENABLE_CPP \
-DMQX_SUPPRESS_FILE_DEF -DRAPIDJSON_HAS_STDSTRING -mcpu=cortex-a5 -mfloat-abi=hard -mfpu=neon-vfpv4 \
-g -D__MQXOS__ -D__GNU__ -D__STRICT_ANSI__  -nostdinc -mthumb -mthumb-interwork -mno-unaligned-access \
-fcommon -ffreestanding -fno-builtin -ftree-vectorize -DGTF_STATIC_BUILD -fvisibility=hidden -Wall \
-Wshadow -Wno-invalid-offsetof -Wuninitialized -fno-strict-aliasing -fshort-enums -fno-exceptions \
-fno-rtti -pipe -fPIC -O3 -DNDEBUG

The target OS is real time system called MQX from Freescale (now NXP).

Do you have any hints, what could be the problem?

Thanks

TR GT
  • 1
  • 1
  • I don't follow your question. What is your exact problem? Are you running into compiler error? You say in windows, everything works fine. So why don't do you paste the output of Windows, so that we can understand your question clearly. – kspviswa Apr 15 '16 at 09:37
  • Sorry. It's compiling without errors both for Windows and my target. At runtime I'm facing the problems only on the target. On Windows parsing the JSON works like excepted. I get a uint64_t for the checksum and an array of ints for the parameters. – TR GT Apr 15 '16 at 10:47
  • Have you tried compile and run the unit tests? It can help to diagnosis platform specific issues. I think it may be due to support of floating point on the platform, or memory alignment issues. – Milo Yip Apr 18 '16 at 00:11

0 Answers0