'simpleError - trailing garbage -Rstudio

im using Rstudio to get data from esp32

i got this error :

simpleError: parse error: trailing garbage 9c ac fb 3f 9c ac fb 3f 6c 36

My code is like this :

str(req$bodyRaw)

print("\n")

data <- jsonlite::parse_json(req$bodyRaw)

print(data)



Solution 1:[1]

Short answer is parse_json requires a "string with literal json or connection object to read from" not a raw vector. From the information provided I have no idea what the structure of req is, but often there is another property such as body that will be the character representation of the body. Alternatively, jsonlite::parse_json(rawToChar(req$bodyRaw))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcus