Skip to main content
Known Participant
September 24, 2008
Answered

How to read and write the data like this(is JSON?)?

  • September 24, 2008
  • 5 replies
  • 617 views
i have some data like below(is json?),how to write them into the database?
i user coldfusion 7.
[
{"title":"ColdFusion?","url":" http://www.adobe.com/cfusion/"},
{"title":"flex blogs","url":" http://www.flexblogs.com/"},
{"title":"studio","url":" http://www.sans.com.com/"}
]

Thank you very much!
    This topic has been closed for replies.
    Correct answer Dan_Bracuk
    You have nested lists. The delimiters are different in each case.

    Google "coldfusion list functions" for ways to approach this.

    In this specific case, you will have to create variables to use as delimters, such as

    delimiterA = '","';

    That's double quote, comma, double quote, by the way, since it's probably hard to read.

    5 replies

    FlashcqxgAuthor
    Known Participant
    September 25, 2008
    Thanks.
    Dan_BracukCorrect answer
    Inspiring
    September 25, 2008
    You have nested lists. The delimiters are different in each case.

    Google "coldfusion list functions" for ways to approach this.

    In this specific case, you will have to create variables to use as delimters, such as

    delimiterA = '","';

    That's double quote, comma, double quote, by the way, since it's probably hard to read.
    FlashcqxgAuthor
    Known Participant
    September 25, 2008
    Thank you,Dan Bracuk and Stressed_Simon .
    the "title" and "url" are the fieldname in my database.
    I had a look at CFJSON,but mine is not JSON formated.

    the square brackets something is the contend i want to insert or update in the database.
    Inspiring
    September 24, 2008
    You need to parse it and then insert the records into your database.

    Take a look at CFJSON it is a JSON serialiser and de-serialiser.

    Once you have converted it to native CF datatypes you can loop through it and insert it into your database.
    Inspiring
    September 24, 2008
    What are the fields in your db, and for the first record, which values do you want to go in each field?

    Also, are the square brackets something you have to contend with, or did you just put them there?

    Finally, does the data really have carraige returns after each record, or just the commas?