Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Sep 24, 2008 Sep 24, 2008
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!
518
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 24, 2008 Sep 24, 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.
Translate
LEGEND ,
Sep 24, 2008 Sep 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?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 24, 2008 Sep 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 24, 2008 Sep 24, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 24, 2008 Sep 24, 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 25, 2008 Sep 25, 2008
LATEST
Thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources