0

The given string Format is given Below:

"{"success":"yes","error":"","message":"","arguments":"[{\"assetId\":\"7384\",\"assetSerialNo\":\"Base Map\",\"assetDescription\":\"\",\"assetVersion\":\"\",\"assetIsMovable\":\"f\",\"assetType\":\"Layer\",\"assetModel\":\"Tile\",\"parentId\":\"7362\",\"assetIsTrackable\":\"f\",\"assetInheritsRegion\":\"f\",\"assetRegion\":\"\",\"typeId\":\"15\"}]"}"

Object within an array and that array is within an Object. But when I parse this string :

document.h is included

Document obj; obj.Parse<0>(json);

It give an error :

document.h:1718:22: note: template rapidjson::GenericDocument& rapidjson::GenericDocument::Parse(const Ch*) [with unsigned int parseFlags = parseFlags, SourceEncoding = SourceEncoding, Encoding = rapidjson::UTF8<>, Allocator = rapidjson::MemoryPoolAllocator<>, StackAllocator = rapidjson::CrtAllocator, rapidjson::GenericDocument = rapidjson::GenericDocument >, rapidjson::GenericDocument::Ch = char] document.h:1729:22: note: template rapidjson::GenericDocument& rapidjson::GenericDocument::Parse(const Ch*) [with unsigned int parseFlags = parseFlags, Encoding = rapidjson::UTF8<>, Allocator = rapidjson::MemoryPoolAllocator<>, StackAllocator = rapidjson::CrtAllocator, rapidjson::GenericDocument = rapidjson::GenericDocument >, rapidjson::GenericDocument::Ch = char]

How I json Decode that format and retrieve assetId .The main object does not have \"\" around string as As this format is returned from an api ?

Ali Raza
  • 7
  • 1
  • 7

1 Answers1

0

According https://jsonlint.com/ a valid JSON would be more like this:

"{"success":"yes","error":"","message":"","arguments":" [{"assetId":"7384","assetSerialNo":"Base Map","assetDescription":"","assetVersion":"","assetIsMovable":"f","assetType":"Layer","assetModel":"Tile","parentId":"7362","assetIsTrackable":"f","assetInheritsRegion":"f","assetRegion":"","typeId":"15"}]}"

Mickael T
  • 895
  • 2
  • 8
  • 19