How to Parse JSON Returned in ColdFusion

前端 未结 3 2055
隐瞒了意图╮
隐瞒了意图╮ 2021-01-15 12:03

I\'m sure this is a relatively simple question, but I can\'t seem to find a simple answer anywhere online.

I have a few lines of JSON returned by a cfhttp POST with

3条回答
  •  清歌不尽
    2021-01-15 13:01

    I forgot to mention that I'm using ColdFusion MX

    Ah, that makes a very big difference! (Unless otherwise stated in the tags, most people will assume a more recent version, like CF9+).

    JSON support was not added until CF8. If you search, there are still some older udf/cfc's for handling JSON out there. For example:

    • JSONDecode at http://www.cflib.org says it works with MX6

    • JSONUtil.cfc works with MX7+. It might work with MX6 out of the box, or with a few modifications. This thread has a description of how to encode with JSONUtil. Decoding should be equally simple. Just create an instance and invoke deserializeJSON, ie:

      
      
      
      

    That said, ColdFusion MX is a bit long in the tooth and no longer supported. You should seriously consider upgrading or switching to the open source Railo engine.

提交回复
热议问题