What are REST resources?

后端 未结 11 1142
青春惊慌失措
青春惊慌失措 2020-11-29 20:53

What are REST resources and how do they relate to resource names and resource representations?

I read a few articles on the subject, but they were too abstract and t

11条回答
  •  抹茶落季
    2020-11-29 21:34

    REST stands for REpresentational State Transfer. It's a method of transferring variable information from one location to another. A common method of doing this is using JSON - a way of formatting your variables so that they can be transferred without loss of information.

    PHP, for example, has built in JSON support. Passing a PHP array to json_encode($array) will output a string in the format you posted (which by the way, is indeed a REST resource, because it gives you variables and information).

    In PHP, the array you posted would turn out as:

    Array (
    
        [0]=>Array (
            ['id']=>6;
            ['name']=>'John';
        )
        [1]=>Array (
            ['id']=>7;
            ['name']=>'Jane';
        )
    
    )
    

提交回复
热议问题