This needs to be decode into readable JSON with Dart the problem is. I don't what it is and I don't know how to do it.
{
mifare: {
identifier: [4, 119, 66, 185, 196, 77, 112],
mifareFamily: 2,
historicalBytes: []
},
ndef: {
isWritable: true,
maxSize: 492,
cachedMessage:
{records:
[{identifier: [],
typeNameFormat: 1,
type: [84],
payload: [2, 101, 110, 123, 39, 99, 109, 100, 39, 58, 39, 110, 101, 119, 95, 102, 114, 105, 101, 110, 100, 39, 44, 39, 117, 115, 101, 114, 39, 58, 39, 116, 101, 115, 116, 39, 125]}]}}}
Someone any idea how to do that? PS: the 'payload' should be text like this:
{'cmd':'new_friend','user':'test'}
CodePudding user response:
If you want to convert this in to your text string, then you need to understand the NDEF data format as this looks like a dump of raw data from reading an NFC card with an Ndef record on it.
Not many libraries have a decoding method only encoding methods.
So the Key points are:-
typeNameFormat: 1
is the code for "Well known Ndef format"
type: [84]
is the code for Ndef Text Record
This leads you to specification for the Ndef text Record https://github.com/haldean/ndef/blob/master/docs/NFCForum-TS-RTD_Text_1.0.pdf
Then
payload: [2, 101, 110, 123, 39, 99, 109, 100, 39, 58, 39, 110, 101, 119, 95, 102, 114, 105, 101, 110, 100, 39, 44, 39, 117, 115, 101, 114, 39, 58, 39, 116, 101, 115, 116, 39, 125]
the
2
is 2 bytes for language identifier length
101
is the decimal code for US ASCII char of e
110
is the decimal code for US ASCII char of n
So the text is in English
123
is the decimal code for US ASCII char of {
etc.
Should have said this is not JSON but a dump of a Javascript Object in Javascript