cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Apoc.load.json Invalid UTF-8

Hi guys.
I'm with a problem when i try to import my json.
[{"CODIGO":1, "NMPRODUTO":"SECADOR DE CABELO Ç", "OBS": { "COR" : "PRETO", "VOLTAGEM" : "18V"}}, {"CODIGO":2, "NMPRODUTO":"CADERNO", "OBS": { "QTDPAGINAS" : 500, "MARCA" : "XYZ"}}]

using this code for import

CALL apoc.load.json("file:///c:/TESTE.json")
YIELD value
create( n:PRODUTO { CODIGO:value.CODIGO,
NMPRODUTO:value.NMPRODUTO,
OBS_COR:value.OBS.COR,
OBS_VOLTAGEM:value.OBS.VOLTAGEM,
OBS_QTDPAGINAS:value.OBS.QTDPAGINAS,
OBS_MARCA:value.OBS.MARCA
})

And neo4j returned this error, because I used 'ç' in my json archive.
But I cant remove this special character(ç)

Failed to invoke procedure `apoc.load.json`: Caused by: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 middle byte 0x22
 at [Source: (apoc.export.util.CountingInputStream); line: 1, column: 48]

Can anyone help me?

1 ACCEPTED SOLUTION

clem
Graph Steward

it seems most probable that your data is bad in someway. Maybe your string is encoded in some system (e.g. one of Microsoft's encodings) instead of UTF-8 (which is more standard nowadays).

see:

You can also use the unix command iconv to convert your encoded strings to UTF-8.

See:

View solution in original post

4 REPLIES 4

clem
Graph Steward

it seems most probable that your data is bad in someway. Maybe your string is encoded in some system (e.g. one of Microsoft's encodings) instead of UTF-8 (which is more standard nowadays).

see:

You can also use the unix command iconv to convert your encoded strings to UTF-8.

See:

Thank's @clem.
I managed to solve the problem using the software "EMEDITOR".
I Opened the json archive and save again with UTF8- encoding and worked very well

I was able to load the file -

call apoc.load.json("file:///2.json") yield value 
merge ( n:PRODUTO { CODIGO:value.CODIGO,
NMPRODUTO:value.NMPRODUTO,
OBS_COR:COALESCE(value.OBS.COR,""),
OBS_VOLTAGEM:COALESCE(value.OBS.VOLTAGEM,""),
OBS_QTDPAGINAS:COALESCE(value.OBS.QTDPAGINAS,""),
OBS_MARCA:COALESCE(value.OBS.MARCA,"")})
Return n

╒════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╕
│"n"                                                                                                                     │
╞════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╡
│{"OBS_VOLTAGEM":"18V","OBS_QTDPAGINAS":"","OBS_MARCA":"","CODIGO":1,"NMPRODUTO":"SECADOR DE CABELO Ç","OBS_COR":"PRETO"}│
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│{"OBS_VOLTAGEM":"","OBS_QTDPAGINAS":500,"OBS_MARCA":"XYZ","CODIGO":2,"NMPRODUTO":"CADERNO","OBS_COR":""}                │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Can you verify the checksum of the json file ?

Sorry, I'm unclear on the your latest response.

I'm not sure what you mean by

Can you verify the checksum of the json file?

but I'm glad it's working now.