Need to remove a JSON line

Sorry seems silly but I can’t get it. So I need to remove lines on a JSON
so I tried a few ways, but grrrr :slight_smile:

----mySettingName

[{
“Y”: 180,
“X”: 560,
“Name”: “Name Number 1”,
},
[],
{
“Y”: 180,
“X”: 620,
“Name”: “Name Number 3”,
}]

tried to remove a line like

mySettingName[2] = {}
saveTable(mySettingName, “Name.json”)
– leaves like ,[],

=========================
–Or
mySettingName[2] = nil
saveTable(mySettingName, “Name.json”)
– leaves like ,null,

I just need to get rid of a full line
so it should look like

----mySettingName

[{
“Y”: 180,
“X”: 560,
“Name”: “Name Number 1”,
}, {
“Y”: 180,
“X”: 620,
“Name”: “Name Number 3”,
}]

1 Like

Tim,

You’re conflating terms which may be part of the confusion.

JSON is an encoding, not a thing in your game.

mySettingName is a TABLE, which is a thing in your game.

You encode your table (using the JSON format) to save it as a text file, then later read the text file and decode it to a table.

JSON, the encoding, allows you to save your in-game table and restore it later.

So, the question is, when you data is in table format (mySettingName), how do you remove an entry?

For that answer, go to the API page: https://docs.coronalabs.com/api/, then find the table.* sub-page (look on left side of API page): https://docs.coronalabs.com/api/library/table/index.html

Now, use the remove function (https://docs.coronalabs.com/api/library/table/remove.html) like this:

table.remove( mySettingName, 2 )

Now, you can re-encode with JSON and save it to file.

1 Like

Thank you roaminggamer
that was what I needed, table I forgot a lot, (well I forgot a lot after my stroke, but I love solar2d) :slight_smile:

table.remove( mySettingName, j )

Glad that helped. Best of luck on your project.