I am new to R and now facing a problem parsing a json column in a dataset, I HAVE GONE THROUGH pretty much all the threads about parsing json, but I CANNOT find a proper solution...as I believe my problem is a little different:
Here is my situation:
I am using R to connect to a SQL database via ODBC && get a table I need:
The TCbigdata is the target json column and the json looks like :
{
"memberid": "30325292",
"hotelgroup": {
"g_orders": "-1",
"g_sfristcreatedate": "-1",
"g_lastcreatedate": "-1",
"g_slastcreatedate": "-1",
"g_fristcreatedate": "-1"
},
"visa": {
"v_orders": "-1",
"v_maxcountryid": "-1",
"v_lastsorderdate": "-1",
"v_maxvisaperson": "-1",
"v_lastorderdate": "-1",
"v_lastvisacountryid": "-1",
"v_sorders": "-1"
},
"callcentertel": {
"lastcctzzycalldate": "-1",
"ishavecctcomplaintcall": "-1",
"lastcctchujingcalldate": "-1",
"lastcctyouluncalldate": "-1"
}....(key n, key n+1.. etc)..}
** My desire output would be all the nested vars , if possible, I want to DELETE memberid && hotelgroup && visa && callcentertel && etc such group keys , so,
1. parsing columns would be like " g_orders...v_orders..lastcct....etc" in one dataset without keys such as "hotelgroup","visa","callcentertel" ...etc...;
2. Or, parsing it into multiple datasets like "hotelgroup" table, COLUMN--"g_orders"+ "g_sfristcreatedate"..... "visa" table, COLUMN--"v_orders"+ "v_maxcountryid".....
I am not sure if there is a package for problem like this?
============ PROBLEM DESCRIPTION && DESIRE OUTPUT =================
I have searched several demonstrations using jsonlite/rjsonio/tidyjson , but failed to find a properway.
**Another part I find confusing is, my dataset, which is from data warehouse via ODBC, return "factor" type of "TCbigdata", instead of "Character" as I assume:
as what it is in DW:
================ MY CODE...TBC ========================
HERE IS MY CODE:
# SQL TABLE orgtc <- sqlQuery(channel1,'SELECT idMemberInfo,memberid, refbizid, crttime, TCbigdata FROM tcbiz_fq_rcs_data.MemberInfo ')
# Convert var_type orgjf$JFMemberPortrait<- as.character( orgjf$JFMemberPortrait )
# ????? ----library(jsonlite) l <- fromJSON(orgjf$JFMemberPortrait, simplifyDataFrame = FALSE) ---- TBD
I appreciate your help!


