Read JSON file with different format -


i have custom platform upload files. platform content of files (mapping) , have screen can see content.

my problem specific json file. original format :

    {"schema:actor:image":"https://link.png","schema:activity.timestamp:timestamp":"01/06/2016 19:23:01","schema:metadata:datatype":"text","schema:actor:name":"aaaa","schema:metadata.tags:key":null,"schema:activity.content:value":"value1","schema:activity.content:language":["english"],"schema:activity.location:placename":"city of london, united kingdom","schema:actor:followers_count":1518,"schema:activity.content:sentiment":"positive","schema:activity.content:opinion":"neutral","schema:activity.content:gender":"unknown","schema:activity.content:age":"35-49","schema:actor:synthetic":"no","schema:activity:original_post":null,"streams":["apollo"]}   {"schema:actor:image":"https://link2.jpg","schema:activity.timestamp:timestamp":"02/06/2016 23:16:39","schema:metadata:datatype":"text","schema:actor:name":"bbbb","schema:metadata.tags:key":null,"schema:activity.content:value":"value2","schema:activity.content:language":["english"],"schema:activity.location:placename":"birmingham, united kingdom","schema:actor:followers_count":28,"schema:activity.content:sentiment":"neutral","schema:activity.content:opinion":"subjective","schema:activity.content:gender":"unknown","schema:activity.content:age":"25-34","schema:actor:synthetic":"no","schema:activity:original_post":"738022479273454944","streams":["apollo"]} 

and cannot use file on platform. way make work alter format bit. format works :

[{"schema:actor:image":"https://link.png","schema:activity.timestamp:timestamp":"01/06/2016 19:23:01","schema:metadata:datatype":"text","schema:actor:name":"aaaa","schema:metadata.tags:key":null,"schema:activity.content:value":"value1","schema:activity.content:language":["english"],"schema:activity.location:placename":"city of london, united kingdom","schema:actor:followers_count":1518,"schema:activity.content:sentiment":"positive","schema:activity.content:opinion":"neutral","schema:activity.content:gender":"unknown","schema:activity.content:age":"35-49","schema:actor:synthetic":"no","schema:activity:original_post":null,"streams":["apollo"]}, {"schema:actor:image":"https://link2.jpg","schema:activity.timestamp:timestamp":"02/06/2016 23:16:39","schema:metadata:datatype":"text","schema:actor:name":"bbbb","schema:metadata.tags:key":null,"schema:activity.content:value":"value2","schema:activity.content:language":["english"],"schema:activity.location:placename":"birmingham, united kingdom","schema:actor:followers_count":28,"schema:activity.content:sentiment":"neutral","schema:activity.content:opinion":"subjective","schema:activity.content:gender":"unknown","schema:activity.content:age":"25-34","schema:actor:synthetic":"no","schema:activity:original_post":"738022479273454944","streams":["apollo"]}] 

the difference in picture here (additions in red color) :

enter image description here

is there way read first file using jsonpath? not familiar jsonpath , not able read first file.

alternatively, thinking of manipulating file in order add missing parts --> make 2nd file.

the problem first json passing several objects {} separated commas, you're not enclosing object or array [].

{},{},{} === bad formed json, 3 orphan objects  { "obj1": {}, "obj2": {}, "obj3": {} } === json, 1 object encloses 3 other objects it's attributes  [ {}, {}, {} ] === json, array of json objects. 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -