New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
poco-1.5.1: Facebook GraphAPI JSON question #64
Comments
Impossible to tell without seeing the JSON itself. I'm quite sure, though, that at some point during "stringifying" you end up here: https://github.com/pocoproject/poco/blob/develop/Foundation/include/Poco/Dynamic/VarHolder.h#L460 inline void VarHolder::convert(std::string& /*val*/) const
{
throw BadCastException("Can not convert to std::string");
} Franky Braem (https://github.com/fbraem) wrote that library so he is the best source of information on it. |
Ok thanks for the info. Franky, is there any documentation/tutorial demonstrating the use of your JSON library ? The benchmark sample is a good start, however, it's a bit bland let's say. |
It'll help if you post a sample of JSON that throws. |
Can you send me an example JSON response from the URL you use? |
Sure, my bad. Here is the JSON response: {"data":[{"name":"Frantisek Zacek","id":"518797070"},{"name":"Clem Ne'me","id":"521787019"},{"name":"Ga\u00eblle Legu\u00e9n\u00e9","id":"523167073"},{"name":"Sylvain Astier","id":"532706918"},{"name":"David Quentin","id":"539806978"},{"name":"Flandre Renaud","id":"559169452"},{"name":"Augustin Rieunier","id":"565503436"},{"name":"Julie Legendre","id":"567007562"},{"name":"Sarah Hosking","id":"572717063"},{"name":"Yann P\u00e9zier","id":"584202620"},{"name":"Denis Rousseau","id":"597972372"},{"name":"Benoit Nesme","id":"604647623"},{"name":"Florent Drillon","id":"609952144"},{"name":"Benjamin Villedieu","id":"633548483"},{"name":"Julien Massenet","id":"635685647"},{"name":"Vincent Remy","id":"658644483"},{"name":"Martin Smurthwaite","id":"670111481"},{"name":"Shanta Raj","id":"680831928"},{"name":"Cyrielle Mehl","id":"682324166"},{"name":"Anne-Fleur Drillon","id":"690978943"},{"name":"FX Singer","id":"699407761"},{"name":"Yann Popo","id":"701439716"},{"name":"Murielle Touret","id":"701911151"},{"name":"Celine Laurencin","id":"710495247"},{"name":"Charles Vionnet","id":"718038682"},{"name":"Geraldine Quenin","id":"729326765"},{"name":"Hadrien Gantzer","id":"781456179"},{"name":"Julie Dupr\u00e9","id":"828462523"},{"name":"Smatti Sofian","id":"842429787"},{"name":"Jef Pommier","id":"1002498019"},{"name":"Jean-Guillaume Desanti","id":"1018251414"},{"name":"Patrick Peinoit","id":"1018307198"},{"name":"Damien Brelivet","id":"1044879509"},{"name":"Arnaud Puy","id":"1080510304"},{"name":"Guillaume Cessieux","id":"1096104649"},{"name":"Perroy Damien","id":"1108765447"},{"name":"Alexandre Demailly","id":"1133658539"},{"name":"Benoit Rivollet","id":"1196713537"},{"name":"Bernard Quenin","id":"1205726565"},{"name":"Marilyn Bass","id":"1218525169"},{"name":"Bastien Perret","id":"1272287731"},{"name":"Karim Tadjene","id":"1277063130"},{"name":"Sophie Ladreyt","id":"1278373214"},{"name":"Paola Jacquemin","id":"1311030773"},{"name":"Agnieszka Jacquemot","id":"1387575444"},{"name":"Annie Suel","id":"1399271494"},{"name":"Laurent Cony","id":"1456958012"},{"name":"Didier Trouvel","id":"1459554573"},{"name":"Delphine Juillot","id":"1484902071"},{"name":"C\u00e9dric Martins","id":"1552565132"},{"name":"Aur\u00e9lie Bert Petrucci","id":"1568276408"},{"name":"Rh\u00e9da Bakir","id":"1616376985"},{"name":"Anthony Poignant","id":"100000969207248"},{"name":"Todd Warwaruk","id":"100001547094911"},{"name":"Miguel Herve","id":"100001565258822"},{"name":"Farah Mahir","id":"100002202791306"},{"name":"Marilyn Ssab","id":"100003069216658"},{"name":"S\u00e9bastien Perret","id":"100003533872156"},{"name":"Glob Ideuh","id":"100003585244509"},{"name":"Isabelle Pourquoipas","id":"100004595822764"},{"name":"Cie K\u00e9roz\u00e8ne","id":"100004688318068"}],"paging":{"next":"https:\/\/graph.facebook.com\/100003057316436\/friends?access_token=BAAGcAvILkyUBABh4NGZCJuj1ZCsHpTROdmbFLs5Dyh4tcZBlR1zaqMmj4MIT348XVwBqwUx2vyBtQxUDO0g62XXXXituSmvrhrYLx0BXZBI9Tgjqrvsez1nnSfqxfQzuuaHBJn2hhb3vDWxIHpGdZCTJ797xgLM82RbjLg9xR06I8V5S1Kg6qDI1werXXqtyl6J2UdAmBdYoZAi1DaxX6lAjwoOfL0PV6cu798A1WNCDgZDZD&limit=5000&offset=5000&__after_id=100004688318068"}} I was just wondering if there was a more substantial example somewhere else, maybe I should file another question then :) Thanks, |
I can't reproduce the problem. This code parses and stringifies fine: std::string fbjson = "{\"data\":[{\"name\":\"Frantisek Zacek\",\"id\":\"518797070\"},{\"name\":\"Clem Ne'me\",\"id\":\"521787019\"},{\"name\":\"Ga\\u00eblle Legu\\u00e9n\\u00e9\",\"id\":\"523167073\"},{\"name\":\"Sylvain Astier\",\"id\":\"532706918\"},{\"name\":\"David Quentin\",\"id\":\"539806978\"},{\"name\":\"Flandre Renaud\",\"id\":\"559169452\"},{\"name\":\"Augustin Rieunier\",\"id\":\"565503436\"},{\"name\":\"Julie Legendre\",\"id\":\"567007562\"},{\"name\":\"Sarah Hosking\",\"id\":\"572717063\"},{\"name\":\"Yann P\\u00e9zier\",\"id\":\"584202620\"},{\"name\":\"Denis Rousseau\",\"id\":\"597972372\"},{\"name\":\"Benoit Nesme\",\"id\":\"604647623\"},{\"name\":\"Florent Drillon\",\"id\":\"609952144\"},{\"name\":\"Benjamin Villedieu\",\"id\":\"633548483\"},{\"name\":\"Julien Massenet\",\"id\":\"635685647\"},{\"name\":\"Vincent Remy\",\"id\":\"658644483\"},{\"name\":\"Martin Smurthwaite\",\"id\":\"670111481\"},{\"name\":\"Shanta Raj\",\"id\":\"680831928\"},{\"name\":\"Cyrielle Mehl\",\"id\":\"682324166\"},{\"name\":\"Anne-Fleur Drillon\",\"id\":\"690978943\"},{\"name\":\"FX Singer\",\"id\":\"699407761\"},{\"name\":\"Yann Popo\",\"id\":\"701439716\"},{\"name\":\"Murielle Touret\",\"id\":\"701911151\"},{\"name\":\"Celine Laurencin\",\"id\":\"710495247\"},{\"name\":\"Charles Vionnet\",\"id\":\"718038682\"},{\"name\":\"Geraldine Quenin\",\"id\":\"729326765\"},{\"name\":\"Hadrien Gantzer\",\"id\":\"781456179\"},{\"name\":\"Julie Dupr\\u00e9\",\"id\":\"828462523\"},{\"name\":\"Smatti Sofian\",\"id\":\"842429787\"},{\"name\":\"Jef Pommier\",\"id\":\"1002498019\"},{\"name\":\"Jean-Guillaume Desanti\",\"id\":\"1018251414\"},{\"name\":\"Patrick Peinoit\",\"id\":\"1018307198\"},{\"name\":\"Damien Brelivet\",\"id\":\"1044879509\"},{\"name\":\"Arnaud Puy\",\"id\":\"1080510304\"},{\"name\":\"Guillaume Cessieux\",\"id\":\"1096104649\"},{\"name\":\"Perroy Damien\",\"id\":\"1108765447\"},{\"name\":\"Alexandre Demailly\",\"id\":\"1133658539\"},{\"name\":\"Benoit Rivollet\",\"id\":\"1196713537\"},{\"name\":\"Bernard Quenin\",\"id\":\"1205726565\"},{\"name\":\"Marilyn Bass\",\"id\":\"1218525169\"},{\"name\":\"Bastien Perret\",\"id\":\"1272287731\"},{\"name\":\"Karim Tadjene\",\"id\":\"1277063130\"},{\"name\":\"Sophie Ladreyt\",\"id\":\"1278373214\"},{\"name\":\"Paola Jacquemin\",\"id\":\"1311030773\"},{\"name\":\"Agnieszka Jacquemot\",\"id\":\"1387575444\"},{\"name\":\"Annie Suel\",\"id\":\"1399271494\"},{\"name\":\"Laurent Cony\",\"id\":\"1456958012\"},{\"name\":\"Didier Trouvel\",\"id\":\"1459554573\"},{\"name\":\"Delphine Juillot\",\"id\":\"1484902071\"},{\"name\":\"C\\u00e9dric Martins\",\"id\":\"1552565132\"},{\"name\":\"Aur\\u00e9lie Bert Petrucci\",\"id\":\"1568276408\"},{\"name\":\"Rh\\u00e9da Bakir\",\"id\":\"1616376985\"},{\"name\":\"Anthony Poignant\",\"id\":\"100000969207248\"},{\"name\":\"Todd Warwaruk\",\"id\":\"100001547094911\"},{\"name\":\"Miguel Herve\",\"id\":\"100001565258822\"},{\"name\":\"Farah Mahir\",\"id\":\"100002202791306\"},{\"name\":\"Marilyn Ssab\",\"id\":\"100003069216658\"},{\"name\":\"S\\u00e9bastien Perret\",\"id\":\"100003533872156\"},{\"name\":\"Glob Ideuh\",\"id\":\"100003585244509\"},{\"name\":\"Isabelle Pourquoipas\",\"id\":\"100004595822764\"},{\"name\":\"Cie K\\u00e9roz\\u00e8ne\",\"id\":\"100004688318068\"}],\"paging\":{\"next\":\"https:\\/\\/graph.facebook.com\\/100003057316436\\/friends?access_token=BAAGcAvILkyUBABh4NGZCJuj1ZCsHpTROdmbFLs5Dyh4tcZBlR1zaqMmj4MIT348XVwBqwUx2vyBtQxUDO0g62XXXXituSmvrhrYLx0BXZBI9Tgjqrvsez1nnSfqxfQzuuaHBJn2hhb3vDWxIHpGdZCTJ797xgLM82RbjLg9xR06I8V5S1Kg6qDI1werXXqtyl6J2UdAmBdYoZAi1DaxX6lAjwoOfL0PV6cu798A1WNCDgZDZD&limit=5000&offset=5000&__after_id=100004688318068\"}}";
Parser parser;
DefaultHandler handler;
parser.setHandler(&handler);
parser.parse(fbjson);
Object::Ptr obj = handler.result().extract<Object::Ptr>();
obj->stringify(std::cout); |
Strange. I ran your code and I get the same error as above (at least its consistent). I run this code on an iOS device, do you think that could be a reason ? I'm gonna investigate more. Thanks for your feedback. |
see if you have this fix in your code: |
Yeah, I have the fix. I found my issue. I messed up my iPhone build configuration file. I forgot to add Here is my build file (if anyone want to use clang c++11/libc++ for iPhone): #
# $Id: //poco/1.4/build/config/iPhone#3 $
#
# iPhone
#
# Build settings for iPhone OS, using Apple's iPhone SDK
#
#
# General Settings
#
# iPhone OS does not allow dynamic linking to user libraries
#
LINKMODE ?= STATIC
#
# If the SDK is defined use it
# Otherwise find the latest version installed
#
IPHONE_SDK_VERSION = 6.0
# if IPHONE_SDK_VERSION_MIN is defined use that
# Otherwise use the version found.
IPHONE_SDK ?= iPhoneOS
IPHONE_SDK_ROOT ?= $(shell xcode-select -print-path)/Platforms/$(IPHONE_SDK).platform/Developer/SDKs
IPHONE_SDK_ROOT_DIR = $(IPHONE_SDK_ROOT)/$(IPHONE_SDK)
IPHONE_SDK_BASE = $(shell ls -d $(IPHONE_SDK_ROOT_DIR)$(IPHONE_SDK_VERSION)*.sdk | tail -1)
IPHONE_SDK_VERSION_MIN ?= $(patsubst %.sdk,%,$(patsubst $(IPHONE_SDK_ROOT_DIR)%,%,$(IPHONE_SDK_BASE)))
POCO_TARGET_OSNAME ?= $(IPHONE_SDK)
POCO_TARGET_OSARCH ?= armv7
TOOL_PREFIX ?= $(shell xcode-select -print-path)/Platforms/$(IPHONE_SDK).platform/Developer/usr/bin
OSFLAGS ?= -arch $(POCO_TARGET_OSARCH) -isysroot $(IPHONE_SDK_BASE) -mthumb -miphoneos-version-min=$(IPHONE_SDK_VERSION_MIN)
#
# Tools
#
# If GCC_VER is defined then use it.
# Otherwise select the latest version
#
# CC = $(shell ls $(TOOL_PREFIX)/llvm-gcc-$(GCC_VER)* | tail -1)
# CXX = $(shell ls $(TOOL_PREFIX)/llvm-g++-$(GCC_VER)* | tail -1)
CC = $(shell xcode-select -print-path)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CXX = $(shell xcode-select -print-path)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
LINK = $(CXX) -bind_at_load
LIB = libtool -static -o
RANLIB = ranlib
SHLIB = $(CXX) $(OSFLAGS) -dynamiclib -Wl,-install_name,$@ -o $@
DYLIB = $(CXX) $(OSFLAGS) -dynamic -bundle -read_only_relocs suppress -Wl,-bind_at_load -o $@
SHLIBLN = $(POCO_BASE)/build/script/shlibln
STRIP =
DEP = $(POCO_BASE)/build/script/makedepend.gcc
SHELL = sh
RM = rm -rf
CP = cp
MKDIR = mkdir -p
#
# Extension for Shared Libraries
#
SHAREDLIBEXT = .$(target_version).dylib
SHAREDLIBLINKEXT = .dylib
#
# Compiler and Linker Flags
#
CFLAGS = $(OSFLAGS)
CFLAGS32 =
CFLAGS64 =
CXXFLAGS = $(OSFLAGS) -Wall -Wno-sign-compare -std=c++11 -stdlib=libc++
CXXFLAGS32 =
CXXFLAGS64 =
LINKFLAGS = $(OSFLAGS)
LINKFLAGS32 =
LINKFLAGS64 =
STATICOPT_CC =
STATICOPT_CXX =
STATICOPT_LINK =
SHAREDOPT_CC = -fPIC
SHAREDOPT_CXX = -fPIC
SHAREDOPT_LINK =
DEBUGOPT_CC = -g -D_DEBUG=$(DEBUGLEVEL)
DEBUGOPT_CXX = -g -D_DEBUG=$(DEBUGLEVEL)
DEBUGOPT_LINK =
RELEASEOPT_CC = -DNDEBUG -O2
RELEASEOPT_CXX = -DNDEBUG -O
RELEASEOPT_LINK =
#
# System Specific Flags
#
SYSFLAGS = -DPOCO_HAVE_IPv6 -DPOCO_NO_FPENVIRONMENT -DPOCO_NO_STAT64 -DPOCO_NO_SHAREDLIBS -DPOCO_NO_NET_IFTYPES
#
# System Specific Libraries
#
SYSLIBS = -ldl -lc++ Thank you for your help. Sorry I've wasted your time :) |
Hi,
I'm using poco to deal with facebook GraphAPI. I managed to do most of the work but i'm struggling with the latest bit. Here is my code:
And here is the output:
As you can see, everything works like a charm except the:
obj->stringify(std::cout);
Any ideas of what I'm doing wrong ?
Thanks,
BQ.
The text was updated successfully, but these errors were encountered: